Ubuntu networking problems – can’t resolve domain names

While setting up my new mini server (Running Ubuntu server edition) I stumbled across what appears to be a semi common problem and, at length, I solved it.

Although I had configured my network interfaces and DNS servers I couldn’t connect to the internet. Specifically I couldn’t resolve hostnames like planet-nifty.co.uk and google.com. I could ping IP addresses inside my home network and IP addresses on the internet too, but pinging domain names like russwilde.com and I would get an error that the domain name couldn’t be resolved.

I must prefix this post with the confession that I know very little about Linux except what I’ve learned while playing around. If you’re playing around like me, be sure you’re well acquainted with the online support facilities – there’s a wealth of information in there.

I must also confess that most of the problems I encountered were created by me not knowing what I was doing.

Step 1: Configure the network interfaces.

My server has two network devices; a wired ethernet card eth0 and a wireless network (Wi-Fi) device wlan0. Both are configured with static IP addresses, although the ethernet device was originally configured via DHCP.

The first problem turned out to be that, in my /etc/network/interfaces file, I had defined a gateway in each interface:


# The loopback network interface
auto lo
iface lo inet loopback
# Cabled network interface
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# WiFi device
auto wlan0
iface wlan0 inet static
address 192.168.1.12
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1 #<-- REMOVE THIS DUPLICATE LINE
wireless-essid monolith
pre-up wpa_supplicant -B -Dwext -iwlan0 -c /etc/wpa_supplicant.conf
post-down killall -q wpa_supplicant

It made sense to me that the gateway should be configured for both connections, but removing one of these was eventually the solution, which probably means the additional gateway and network definitions in wlan0 could be removed too. Once I removed the second gateway definition in wlan0 things started to work.

The second problem turned out to be that I , foolishly had defined four DNS servers in my /etc/resolv.conf , which also was wrong:

nameserver 208.67.222.222
nameserver 208.67.220.220
nameserver AAA.BB.CCC.DDD #My ISP Primary Name Server
nameserver AAA.BB.CCC.DDD #My ISP Secondary NameServer <-- REMOVE -- You can only have three

Incidentally, if you’re wondering about the wpa_supplicant business, or if you’re having problems setting up your wifi through the terminal. I followed a handy tutorial on mini-itx.com to setup my wireless network connection. It was written for XBMC, but works equally well for Ubuntu.

So there you go, hopefully this will help someone who, like me doesn’t know what they’re doing.

Leave a Reply