/etc/resolv.conf

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
My Comcast DNS servers were down, so I wanted to add a universal DNS (4.2.2.1) to /etc/resolv.conf. I commented out:

#search localdomain
#nameserver 172.16.143.2

And added:

nameserver 4.2.2.1

Yet, every 20 minutes or so, the whole file is deleted and replaced with

search localdomain
nameserver 172.16.143.2

again, and my DNS ceases to work. What gives?
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
Hmm...yes I am using DHCP. Can I use DHCP for my IP address but not for my DNS servers?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: xtknight
Hmm...yes I am using DHCP. Can I use DHCP for my IP address but not for my DNS servers?

Yep. I couldn't tell you how though. It depends on your dhcp client, and I've never read the docs for any but dhclient, and those I didn't read well because I didn't care. :p
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
I'm using dhclient. ;)

Turns out I just had to add this to /etc/dhcp3/dhclient.conf. Then rerun dhclient.

prepend domain-name-servers 4.2.2.1;

Thanks for the clue it was DHCP.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: xtknight
I'm using dhclient. ;)

Turns out I just had to add this to /etc/dhcp3/dhclient.conf. Then rerun dhclient.

prepend domain-name-servers 4.2.2.1;

Thanks for the clue it was DHCP.

That's a pretty simple fix. :beer:
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
I spoke a little too soon. It did it again, but then when I ran dhclient, it added the 4.2.2.1 DNS back. Very odd.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
dhclient doesn't stop running. Unless you restarted it, it probably just used the original configuration.
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
I did:
sudo /etc/init.d/networking restart

And now even my Comcast DNS servers seem to be working. Prior to this problem my network had for some reason just broken itself, so maybe the networking daemon took a dump.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
There's no singular 'networking daemon' and I wouldn't trust the networking init script to restart the DHCP client, I would have done 'ifdown ethX', made sure that dhclient was killed and then ran 'ifup ethX'.
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
Never mind. I had figured out that after restarting the networking init.d service my regular DNS were working again. My cable modem was having issues this morning (it took 10 mins to start), so I'm going to attribute the problem to that. Plus, dhclient was grabbing an IP for my vmware instead of my eth0 unless I specified otherwise, so maybe that was it. It has been fine all today (since a cable modem, router, system restart).

pkill? Is that different than kill?

Edit: Actually now the thing is working like it's supposed to (the system reboot restarted something that now has the new config in memory?) 4.2.2.1 has been added to resolv.conf after the 'search' line. Maybe that is why my DNS is fine now. Whatever, I'm going to leave it like this for a week or so and then change back to Comcast's DNS.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: xtknight
Never mind. I had figured out that after restarting the networking init.d service my regular DNS were working again. My cable modem was having issues this morning (it took 10 mins to start), so I'm going to attribute the problem to that. Plus, dhclient was grabbing an IP for my vmware instead of my eth0 unless I specified otherwise, so maybe that was it. It has been fine all today (since a cable modem, router, system restart).

pkill? Is that different than kill?

Yes. kill requires the pid number, pkill doesn't.