Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
127
rated 0 times [  127] [ 0]  / answers: 1 / hits: 435101  / 1 Year ago, mon, march 20, 2023, 9:21:50

After updating /etc/network/interfaces with something very similar to below, how do I get /etc/resolv.conf to update? I tried (as root) resolver -u, service networking restart but they didn't work. I also fixed the symlink for resolv.conf and tried resolver -u again. Finally in frustration I rebooted, which did fix the problem by rebuilding /etc/resolv.conf.



Ubuntu 12.04, 64bit server, all the latest patches installed.



Example /etc/network/interfaces:



iface eth0 inet static
address 192.168.3.3
netmask 255.255.255.0
gateway 192.168.3.1
dns-search example.com
dns-nameservers 192.168.3.45 192.168.8.10

More From » server

 Answers
5

service networking restart is not always a reliable way of down-upping all interfaces.



The resolvconf -u command only updates resolv.conf from resolvconf's own database. You need to update the database.



To update the database you have to call resolvconf with the -a or -d option. That happens behind the scenes when you run ifup or ifdown. So, normally, as with any other change to /etc/network/interfaces, to activate changes to the dns-* options you have to ifdown the interface in question and ifup it again. Or you can reboot.



If you want to make changes to an interface without ifdownupping it (perhaps because you are administering the machine remotely and happen to be connected via that interface, natch) then you can achieve the same result by running resolvconf directly from the command line. This requires a bit more knowledge of resolvconf's semantics. Assume the relevant /e/n/i stanza is



iface IIII FFFF static
address ...
...
dns-nameservers X.X.X.X Y.Y.Y.Y
dns-search SSSS


where FFFF is an address family ("inet" or "inet6").



To activate these dns-* options you run resolvconf as follows (yes, with newlines in the string piped to resolvconf).



echo "nameserver X.X.X.X
nameserver Y.Y.Y.Y
search SSSS" | sudo resolvconf -a IIII.FFFF


For the stanza given in the question this would be the following.



echo "nameserver 192.168.3.45
nameserver 192.168.8.10
search example.com" | sudo resolvconf -a eth0.inet


Consult the resolvconf(8) manual page and the resolvconf package README file (/usr/share/doc/resolvconf/README.gz) for more information.


[#33896] Wednesday, March 22, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
puccop

Total Points: 66
Total Questions: 99
Total Answers: 93

Location: Aruba
Member since Sun, Nov 27, 2022
1 Year ago
puccop questions
Thu, Feb 17, 22, 08:16, 2 Years ago
Fri, Jan 13, 23, 18:55, 1 Year ago
Fri, Jan 21, 22, 07:21, 2 Years ago
Thu, Jul 28, 22, 06:32, 2 Years ago
;