0

When I switch between different networks with different dhcp servers, my resolv.conf file doesn't change (other settings like ip and gw change).

Workaround is to remove resolv.conf and run dhclient manually.

My interfaces file looks like this:

cat /etc/networK/interfaces

auto lo iface lo inet loopback

How to fix it permanent?

Bruno Pereira
  • 73,643

3 Answers3

0

I had same issue a while back, and it was because the resolvconf package was not install. try to install it using

sudo apt-get install resolvconf

then edit resolvconf file and restart the network via

sudo /etc/init.d/networking restart

also what does your /etc/network/interfaces file look like?

I also got a tip from this answer in a previous thread similar to yours. https://askubuntu.com/a/58802/49237

A possible trigger for the seemingly spontaneous updates to /etc/resolv.conf is when your DHCP lease is renewed. Check how long you get DHCP leases for (this should appear in the system logs, I think in /var/log/syslog).

You can use auditd to find out what modifies the file. Start the daemon (sudo service auditd start) and tell it to watch for modifications to that file:

sudo auditctl -w /etc/resolv.conf -p w

Audit logs are in /var/log/audit/audit.log. You'll see the time the file was modified and the name of the program that modified it.

If you have the resolvconf package installed, Network Manager may be stepping on its toes. Try bringing all network interfaces down, then stop Network Manager (sudo service network-manager stop), then restart it.

kmassada
  • 1,376
-1

From the fact that you have no iface definitions in /etc/network/interfaces I infer that you are using NetworkManager to configure your interfaces.

Possibly the original problem was misconfigured connections in NetworkManager, e.g., having selected "Automatic (DHCP) addresses only" instead of "Automatic (DHCP)" as the "Method".

Also consider the possibility that your symbolic link /etc/resolv.conf -> ../run/resolvconf/resolv.conf was missing for one reason or another. See bug #1000244. The fix for that would have been to run "dpkg-reconfigure resolvconf".

Removing resolvconf was not the best solution. By doing that you are relying upon legacy support in the DHCP client for directly futzing with /etc/resolv.conf. That may work for now, but resolvconf was introduced precisely in order to bring order to that kind of intervention.

jdthood
  • 12,467
-3

I fix it by removing resolvconf.