diffrence between the DNS setting in etc/resolv conf and etc/network/interfaces

I want to know the difference between DNS settings in /etc/resolv.conf and /etc/network interfaces. For example when I share internet connection from other computer(XP), I used to add the name server (DNS address of my ISP) in /etc/resolv.conf and I could successfully share the internet. But I want to know what is the relevance of setting the DNS address in the /etc/network/interfaces along with IP and gateway address?

Where does my computer look up for resolving IP address of some website when browsing? Is it resolv.conf or network interfaces?


Solution 1:

Newer Ubuntu systems use a service called resolvconf that runs a local DNS resolver on the machine, and automatically manages the /etc/resolv.conf file (in fact, as a symlink to somewhere in the /run filesystem) and you should not edit the /etc/resolv.conf file by hand.

In the server version, resolvconf takes the actual server addresses either via DHCP or from /etc/network/interfaces file where they are specified as a list of dns-nameservers e.g.


auto eth0
iface eth0 inet static
address 192.168.1.102
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 192.168.1.1 8.8.4.4

For the desktop versions (i.e. those using the network-manager service and associated GUI applet) the actual servers come either via DHCP or may be specified in the IPv4 Settings tab after changing the Method: from Automatic (DHCP) to either Automatic (DHCP) addresses only or Manual and adding the required IP addresses in the boxes provided.