1

I have set up my /etc/bind to set up the following:

dig @127.0.0.1 +noall +answer SRV _my-sub._tcp.example.com

_my-sub._tcp.example.com. 300 IN SRV 0 0 12379 a0.example.com.
_my-sub._tcp.example.com. 300 IN SRV 0 0 22379 a1.example.com.
_my-sub._tcp.example.com. 300 IN SRV 0 0 32379 a2.example.com.


dig @127.0.0.1 +noall +answer a0.example.com a1.example.com a2.example.com

a0.example.com. 300 IN  A   127.0.0.1
a1.example.com. 300 IN  A   127.0.0.1
a2.example.com. 300 IN  A   127.0.0.1

And now I want to edit my /etc/resolv.conf to get the same results without @127.0.0.1. How do I overwrite resolv.conf to achieve this?

Thanks!

dig +noall +answer a0.example.com a1.example.com a2.example.com

Should return:

a0.example.com. 300 IN  A   127.0.0.1
a1.example.com. 300 IN  A   127.0.0.1
a2.example.com. 300 IN  A   127.0.0.1
1
  • What is the ubuntu version you use? You can add a record to resolv.conf but in newer ubuntu OS's it will be overwritten on reboot.
    – eranga
    Jan 13, 2016 at 10:55

2 Answers 2

1

You can either remove all nameserver references from your resolv.conf or you can add a specific

nameserver 127.0.0.1 

to your file. Note that if you add multiple nameserver entries they are tried in the order they are defined. Note also that the maximum is currently three.

You should probably read the documentation, resolv.conf(5).

2

Bear in mind that BIND (and the zone files and such in /etc/bind) acts as a directory of sorts: it lists the hosts that exist in example.com, what their IP addresses are, and that sort of thing.

/etc/resolv.conf, on the other hand, tells your machine where to look up information in DNS. Just because a machine is running a nameserver doesn't mean that it has to use it (there might be times when you don't want to use the same DNS data you provide to others).

So when you ask how to avoid having to use @127.0.0.1, you're really asking, "How can I set 127.0.0.1 as the default nameserver?". As Iain said, add nameserver 127.0.0.1 to your /etc/resolv.conf.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .