We have an SMTP only mail server behind a firewall which will have a public A record of mail.. The only way to access this mail server is from another server behind the same firewall. We do not run our own private DNS server.

Is it a good idea to use the private IP address as an A record in a public DNS server - or is it best to keep these server records in each servers local hosts file?

10 Answers 10


Some people will say no public DNS records should ever disclose private IP addresses....with the thinking being that you are giving potential attackers a leg up on some information that might be required to exploit private systems.

Personally, I think that obfuscation is a poor form of security, especially when we are talking about IP addresses because in general they are easy to guess anyway, so I don't see this as a realistic security compromise.

The bigger consideration here is making sure your public users don't pickup this DNS record as part of the normal public services of your hosted application. ie: External DNS lookups somehow start resolving to an address they can't get to.

Aside from that, I see no fundamental reason why putting private address A records into the public space is a problem....especially when you have no alternate DNS server to host them on.

If you do decide to put this record into the public DNS space, you might consider creating a separate zone on the same server to hold all the "private" records. This will make it clearer that they are intended to be private....however for just one A record, I probably wouldn't bother.

  • +1, see comment to womble's answer for reason :) – Mihai Limbăşan May 5 '09 at 16:20
  • 2
    This is a good example of an issue with this idea: merit.edu/mail.archives/nanog/2006-09/msg00364.html – sucuri Aug 4 '09 at 19:12
  • Does this advice still apply if you have sensitive servers with public IP addresses, but behind a firewall restricting access? If the public DNS for the public IP addresses gives a roadmap of the infrastructure, isn't that some use to an attacker? Host identification? – Kenny Nov 28 '11 at 12:51
  • @Kenny Yes, in theory this does have some use, but it is information that is not hard to get because the range of public IP addresses are readily discoverable anyway. I kind of addressed this in the answer and adding to that notion I would argue that if you are depending on hiding IP addresses or hostnames as any kind of material line of defense, you have much much bigger problems already. – Tall Jeff Nov 28 '11 at 14:12
  • 1
    @Kenny To your point, it's certainly desirable to minimize the amount of information that is publicly discoverable and you would not want to disclose something that you didn't need to or didn't at least have some kind of good cost/benefit trade-off involved to consider it. No argument there. Aside from that, the core of my point (and I think we agree) was simply that that obfuscation is a poor form of security and that there is no absolute good/bad, but only a continuum of cost/benefit trade-offs to be considered on a case-by-case basis depending on your risk tolerance, etc. – Tall Jeff Nov 28 '11 at 18:17

I had a lengthy discussion on this topic on the NANOG list a while ago. Though I'd always thought it was a bad idea, turns out that it's not such a bad idea in practice. The difficulties mostly come from rDNS lookups (which for private addresses Just Don't Work in the outside world), and when you're providing access to the addresses over a VPN or similar it's important to ensure that the VPN clients are properly protected from "leaking" traffic when the VPN is down.

I say go for it. If an attacker can get anything meaningful from being able to resolve names to internal addresses, you've got bigger security problems.

  • 1
    +1, thank you for being a voice of sanity in all the FUD responses to this question. "Security risk" my lower dorsal regions, and seeing routing problems and DNS issues colluded into one knee-jerk "don't do it" reaction just makes me wonder about the competence of people running networks all over the place. – Mihai Limbăşan May 5 '09 at 16:19
  • 1
    Correction: Make that "seeing routing problems and DNS issues and authentication/identity issues colluded". – Mihai Limbăşan May 5 '09 at 16:32

In general introducing RFC1918 addresses into public DNS will cause confusion, if not a real problem, at some point in the future. Use IPs, host records, or a private DNS view of your zone to use the RFC1918 addresses behind your firewall but not include them in the public view.

To clarify my response based on the other submitted response, I think introducing RFC1918 addresses into public DNS is a faux pas, not a security issue. If someone calls me to trouble shoot an issue and I stumble across RFC1918 addresses in their DNS, I start talking really slowly and asking them if they've rebooted recently. Maybe that's snobbery on my part, I don't know. But like I said, it's not a necessary thing to do and it's likely to cause confusion and miscommunication (human, not computer) at some point. Why risk it?

  • 1
    What real problem(s) are these? In what ways will people be confused? – womble May 5 '09 at 2:30
  • 2
    So it's... polite... not to put 1918 addresses into public DNS? I've hit plenty of problems that "hidden" and "split horizon" DNS zones have caused, but not nearly so many caused by private IP in public DNS. I just don't see the problem. – womble May 5 '09 at 2:36
  • 3
    @womble, computers might be confused if for some reason they attempt to connect to that host outside your network and instead of getting the SMTP server they expected they got whatever was living at that IP address on the lan they where currently connected to. It could even be that one of your staff using a laptop on a remote might start spewing the user name and password out in plain-text on someone else's network just because they also happen to have a – Zoredache May 5 '09 at 2:53
  • 17
    The problem I have with your answer is that you allude to problems, but don't provide any details. If there are reasons not to do it, I want to know about them, so I can make a fully reasoned decision on the subject. – womble May 5 '09 at 2:53
  • 1
    @Zoredache: Why is someone resolving a name they don't have access to? DNS isn't the only place you could get private addresses, anyway -- HTML can use IP literals, for instance... – womble May 5 '09 at 2:56

No, don't put your private IP addresses in the public DNS.

Firstly, it leaks information, although that's a relatively minor problem.

The worse problem if your MX records point to that particular host entry is that anyone that does try to send mail to it will at best get mail delivery timeouts.

Depending on the sender's mail software they may get bounces.

Even worse, if you're using RFC1918 address space (which you should, inside your network) and the sender is too, there's every chance that they'll try and deliver the mail to their own network instead.

For example:

  • network has internal mail server, but no split DNS
  • admin therefore puts both public and internal IP addresses in the DNS
  • and MX records point to both:

 $ORIGIN example.com
 @        IN   MX    mail.example.com
 mail     IN   A
          IN   A     some_public_IP

  • someone seeing this might try to connect to
  • best case, it bounces, because they've got no route
  • but if they've also got a server using, the mail will go to the wrong place

Yes, it's a broken configuration, but I've seen this (and worse) happen.

No, it's not DNS's fault, it's just doing what it's told to.

  • How is delivering mail to the wrong machine a DNS problem? You should authenticate the SMTP server. That's a SMTP configuration problem which has absolutely nothing to do with DNS. You're not even comparing apples to oranges here, you're comparing a radioactive buttered toast to five milligrams of Lagrangian derivatives on a stick. If you're worrying about getting the wrong MX or A result you should use DNSSEC instead of holding DNS responsible for what it's not responsible, and if you're mistakenly delivering SMTP to the wrong RFC1918 number you've misconfigured or misdesigned your network. – Mihai Limbăşan May 5 '09 at 16:27
  • (reposted commend for clarification) – Mihai Limbăşan May 5 '09 at 16:28
  • If someone on your network "made up" an IP number then the IP protocol is functioning exactly as designed, i.e. without security in mind. What you are asking is "how can I trust that I'm actually talking to whomever I'm supposed to talk to?" and the answer to that cannot be delivered by IP and/or by DNS, the answer to that is delivered by DNSSEC and/or SSL/TLS and/or an application layer mechanism. – Mihai Limbăşan May 5 '09 at 16:30
  • Just read your comment to Dave's post - your post makes more sense now :) I still disagree with the premise, but I don't think it's irrational anymore... – Mihai Limbăşan May 5 '09 at 16:35
  • 2
    no, it wasn't about authentication at all, just about connections ending up in the wrong place. I saw plenty of that when Verisign decided to wildcard *.com back in ~2001. – Alnitak May 5 '09 at 16:46

Though the possibility is remote I think you may be setting yourself up for some of MITM attack.

My concern would be this. Lets say one of your users with a mail client configured to point at that mail server takes their laptop to some other network. What happens if that other network also happens to have the same RFC1918 in use. That laptop may attempt to login to the smtp server and offer the user's credentials to a server that shouldn't have it. This would be particularly true since you said SMTP and didn't mention that you where requiring SSL.

  • If the user has a laptop they use in your office as well as elsewhere, chances are they'll have configured their hosts file to point at the internal IP of the MTA, or used the IP directly in their MUA config. Same end result. Bring on IPv6 and the death of RFC1918, it's the only way to be sure... – womble May 5 '09 at 3:00
  • Excellent point Zoredache. This is an interesting attack vector. Depending on the MUA it might present the usual "something annoying happened, please click me to do what you wanted me to do in the first place" dialog box, or it could fail outright if the ssl cert doesn't match. – Dave Cheney May 5 '09 at 16:33
  • Is this attack scenario effectively eliminated if all servers (namely web/HTTPS, IMAP, and SMTP) in the valid network require SSL/TLS-based client connections? – Johnny Utahh Sep 23 '19 at 10:53
  • @JohnnyUtahh, well you need all servers to support TLS, with valid certs and you need all clients to be configured to verify the certs, and never try a non-TLS connection. Which is a more common default now, then 10 years ago. But there is still old/stupid software that might try non-tls connections. – Zoredache Sep 23 '19 at 21:48
  • Yep, all makes sense, thanks @Zoredache. – Johnny Utahh Sep 23 '19 at 23:42

Your two options are /etc/hosts and putting a private IP address in your public zone. I'd recommend the former. If this represents a large number of hosts, you should consider running your own resolver internally, it's not that hard.

  • 1
    That's certainly an option, but why? What does running an internal resolver or (much smarter) using something like BIND views gain you beside administrative overhead and maintenance burden? That's what I don't understand. – Mihai Limbăşan May 5 '09 at 16:10
  • 1
    Running your own name server is not rocket science. If your network is of a sufficient size that you consider using /etc/hosts as a hack or to time consuming, then you need to setup a pair of resolvers in your network. As a side benefit you reduce the amount of dns traffic leaving your network and you speed up resolution of common queries. – Dave Cheney May 5 '09 at 16:17
  • 3
    I know it's not rocket science, but it's a maintenance overhead and a potential security risk. Certainly a higher security risk than leaking the existence of a RFC1918 network. DNS traffic is utterly negligible - I host in excess of 80 moderately large and busy zone files on my DNS at work and weekly DNS traffic is less than 2 minutes of Youtube. Speeding up query resolution is actually the first halfway sane argument against RFC1918 numbers in DNS I've seen here :) Upvoted for actually thinking a bit beyond the usual knee-jerk "oh, noes, it's a security risk" reaction :) – Mihai Limbăşan May 5 '09 at 16:23
  • 1
    @Alnitak: I understand where you're coming from but that's still not a DNS problem, and I maintain that trying to fix issues originating somewhere else through DNS is not a good idea at all. Problems should be fixed at the source, not patched up by DNS hacks - hacks make networks brittle. – Mihai Limbăşan May 5 '09 at 16:34
  • 2
    well, yes, I agree. And putting your private host's information in the public DNS is a hack solution for the problem of not having an internal DNS server... :) The problem is that the higher layers don't know that this information is supposed to be "private". – Alnitak May 5 '09 at 16:44

There may be subtle problems with it. One is that common solutions to DNS Rebind attacks filter local DNS entries resolved from public DNS servers. So you either open yourself to rebind attacks, or local addresses don't work, or require more sophisticated configuration (if your software/router even allows it).


It's best to keep it in the hosts file. If only one machine is ever supposed to connect to it anyway, what do you gain by putting it into public DNS?

  • Working in the cloud you could have thousands of private machines. A few years back, Netflix said they had 2,000+ Cassandra nodes. That's not practical to use the /etc/hosts file because all 2,000 machines then need to manage these IP/name pairs... – Alexis Wilke Mar 15 '19 at 23:36

If by private you mean a, a, or a, then don't. Most internet routers recognize it for what it is - a private address that must never be routed to the public internet in a direct fashion, which is what helped the popularity of NAT. Anyone attempting to contact your public DNS server will retrieve the private IP address from DNS, only to send a packet to .... nowhere. As their connection attempts to traverse the internet to your private address, some (sanely configured) router along the way will simply eat the packet alive.

If you want to get email from the "outside" to come "inside", at some point, the packet has to cross your firewall. I would suggest setting up a DMZ address to handle this - a single public IP address that is tightly controlled by any router/firewall you have in place. The existing setup you describe sounds like it does exactly that.

EDIT: clarification of intent... (see comments below). If this doesn't make sense, I'll vote to remove my own post.

  • 3
    That's all nice and true, but you haven't given an actual reason for why one should not publish RFC1918 addresses in DNS. You have just described what RFC1918 addresses are and that it's possible to not have a route to some of them. How is that different from any other IP number? It's possible to not have a route to - does that mean it's wrong to publish in DNS? DNS is a name resolution system. It has nothing to do with routing, the two are orthogonal. You're colluding two categories of problems, which basically amounts to FUD. – Mihai Limbăşan May 5 '09 at 16:16
  • 1
    The context of the discussion was the use of private IP addresses in a public DNS server. The point of the post was to indicate that, by default, routers are not to route private IP addresses. I was not attempting to indicate that you can't use private IP addresses in a DNS server, only that you shouldn't provide those IP addresses "to the outside". If this is not clear enough, I'll gladly withdraw the post. Otherwise, I disagree, the post is 100% spot-on - the net effect for this person is that /they will have problems/ if they do this. – Avery Payne May 5 '09 at 16:43
  • nods Your comment under Alnitak's post cleared it up :) Thanks. – Mihai Limbăşan May 5 '09 at 17:19
  • 1
    "Anyone attempting to contact your public DNS server will retrieve the private IP address from DNS, only to send a packet to .... nowhere" - nope, you have actually just described DNS rebinding and it works on some of the most secure routers out there, including my PepWave Surf SOHO: rebind.network/rebind – Ohad Schneider Jun 22 '18 at 20:45

I arrived here as I was looking for similar information and was surprised that many say it's fine to leak your private IP addresses. I guess in terms of being hacked, it doesn't make a huge difference if you are on a safe network. However, DigitalOcean has had all local network traffic on the exact same cables with everyone really having access to everyone else traffic (probably doable with a Man in the Middle attack.) If you just would get a computer in the same data center, having that information certainly gives you one step closer to hacking my traffic. (Now each client has its own reserved private network like with other cloud services such as AWS.)

That being said, with your own BIND9 service, you could easily define your public and private IPs. This is done using the view feature, which includes a conditional. This allows you to query one DNS and get an answer about internal IPs only if you are asking from your one of your own internal IP address.

The setup requires two zones. The selection uses the match-clients. Here is an example of setup from Two-in-one DNS server with BIND9:

acl slaves {;    // XName; // XName;  // XName

acl internals {;;

view "internal" {
    match-clients { internals; };
    recursion yes;
    zone "example.com" {
        type master;
        file "/etc/bind/internals/db.example.com";
view "external" {
    match-clients { any; };
    recursion no;
    zone "example.com" {
        type master;
        file "/etc/bind/externals/db.example.com";
        allow-transfer { slaves; };

Here is the external zone and we can see IPs are not private

; example.com
$TTL    604800
@       IN      SOA     ns1.example.com. root.example.com. (
                     2006020201 ; Serial
                         604800 ; Refresh
                          86400 ; Retry
                        2419200 ; Expire
                         604800); Negative Cache TTL
@       IN      NS      ns1
        IN      MX      10 mail
        IN      A
ns1     IN      A
mail    IN      A ; We have our mail server somewhere else.
www     IN      A
client1 IN      A ; We connect to client1 very often.

As for the internal zone, we first include the external zone, which is how it works. i.e. if you are an internal computer, you only access the internal zone so you still need the external zone definitions, hence the $include command:

$include "/etc/bind/external/db.example.com"
@       IN      A
boss    IN      A
printer IN      A
scrtry  IN      A
sip01   IN      A
lab     IN      A

Finally, you have to make sure that all your computers now make use of that DNS and its slaves. Assuming a static network, it would mean editing your /etc/network/interfaces file and using your DNS IPs in the nameserver option. Something like this:

iface eth0 inet static
    nameserver ...

Now you should be all set.

  • If attacker can potentially do something they shouldn't with your network resources, and all they are missing is the IP address... you're doing it wrong. – csauve Mar 11 at 23:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.