I'm having trouble getting my CentOS 5.5 EC2 instances (both i386 and x86_64) to properly populate resolv.conf after booting. No matter what I do, I end up with the default EC2 resolv.conf:

; generated by /sbin/dhclient-script
search compute-1.internal
nameserver 172.16.0.23

What I really want to do is set my own search domain and prepend two nameservers. First, I tried adding /etc/dhclient.conf:

prepend domain-name "mydomain.ec2 "
prepend domain-name-server 1.2.3.4
prepend domain-name-server 1.2.3.5

That didn't work. So I also tried placing the dhclient.conf file in /etc/dhcp/ and /etc/dhcp3. Neither worked. So I also tried creating /etc/dhclient-enter-hooks and overriding the _make_resolv_conf()_ method to prevent dhclient-script from overwriting resolv.conf:

make_resolv_conf() {
 ;
}

That had no impact either.

The only solution I have come up with is to add an extra init script that rewrites resolv.conf. That works, but I'd really like to do this the "right" way. What am I doing wrong?

link|improve this question

67% accept rate
Did you try PEERDNS=no? – dmourati May 31 '11 at 23:23
feedback

2 Answers

Try adding:

PEERDNS=no

To your /etc/sysconfig/network-scripts/ifcfg-eth0 (or equivalent)

If that doesn't work, you could use the chattr hack:

chattr +i /etc/resolv.conf
link|improve this answer
feedback

This should address your issue http://www.linuxquestions.org/questions/linux-networking-3/how-to-avoid-resolv-conf-been-modified-by-dhcp-client-422431/

link|improve this answer
Nope. As I mentioned, I tried using dhclient.conf and that didn't have any effect. – organicveggie May 24 '11 at 19:42
feedback

Your Answer

 
or
required, but never shown

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