This answer is similar to the one above but uses the questions example configuration to answer the question. Plus this explains why both commands are necessary.
Edit /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-nameserver 192.168.3.45
dns-nameserver 192.168.8.10
These changes will not take place unless you reboot or reload the configuration file:
In order to update the interfaces file live it is necessary to run the following command:
echo "nameserver 192.168.3.45
nameserver 192.168.8.10
search example.com" | sudo resolvconf -a eth0.inet
This allows an update to the interface without a reboot or reloading.
However, the above command changes will be lost after a reboot if the changes in the /etc/network/interfaces
are not made.
By the way the last answer from BDenis in this list actually works in place of the last command by parsing the /etc/network/interfaces
file and piping those lines into the command sudo resolvconf -a eth0
It's actually half the answer and a really good example of inline sed parsing. If you want to see how it does this just run the first part of the command and watch it parse the /etc/network/interfaces
file and spit out all the necessary information you need to run the sudo resolvconf -a eth0
command:
sed 's/#.*$//' /etc/network/interfaces | grep dns- | sed 's/dns-//g'
Notice this would produce the same out put as the command:
echo "nameserver 192.168.3.45
nameserver 192.168.8.10
search example.com"
Provided that the /etc/network/interfaces
file is configured with this information:
iface eth0 inet static
address 192.168.3.3
netmask 255.255.255.0
gateway 192.168.3.1
dns-search example.com
dns-nameserver 192.168.3.45
dns-nameserver 192.168.8.10