Saturday, 2 January 2016

How to enable name resolution for Ubuntu 14.04 server using resolv.conf,DNSMasq and network configuration

Recently I faced the issue where in one of my Ubuntu servers, I'm unable to set up the name servers in /etc/resolv.conf . Whenever I set this and restart networking or resolvconf, it is getting overwritten. This was causing me issues as I'm unable to ping google.com. This is what I'm getting when I ping.

[email protected]:~# ping google.com
ping: unknown host google.com



So the solution is to edit the /etc/network/interfaces file and add the entry "dns-nameservers 8.8.8.8 8.8.4.4" .

My network configuration is given below:

[email protected]:~# cat /etc/network/interfaces 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.0.10
        netmask 255.255.255.0
        gateway 192.168.0.1
dns-search example.com
dns-nameservers 8.8.8.8 8.8.4.4

Then restart networking.

[email protected]:~# /etc/init.d/networking restart
 * Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
 * Reconfiguring network interfaces...                                                                                                                                  ssh stop/waiting
ssh start/running, process 6194

You can see that ping is now working fine.

[email protected]:~# ping google.com
PING google.com (74.125.226.69) 56(84) bytes of data.
64 bytes from lga15s44-in-f5.1e100.net (74.125.226.69): icmp_req=1 ttl=55 time=9.84 ms
64 bytes from lga15s44-in-f5.1e100.net (74.125.226.69): icmp_req=2 ttl=55 time=10.9 ms

No comments:

Post a Comment