So yesterday and today I've been having fun with a little problem with the latest Ubuntu 12.04 LTS server, and setting a static IP Address. The fun is that when you use a static address, you also need to include the DNS specification with it. I went the way of modifying the /etc/network/interfaces file to set my IP address. What I found out in the end is that the file has to look something like this:
# The primary network interface
auto eth0
iface eth0 inet static
address 10.0.1.17
netmask 255.255.255.0
gateway 10.0.1.1
network 10.0.1.0
broadcast 10.0.1.255
dns-search kingsleylocal.com
dns-nameservers 10.0.1.14 208.67.220.220
The first 5 lines are normal for past Ubuntu versions, but the last two are new. So with 12.04, you need to specify the DNS nameservers by setting the line dns-nameservers and then the IP address of the servers that you want to use separated with a space. Then if you have a local domain as well, you can let the server know about it by dns-search and that will search you local network for matches. After I set this I modified /etc/resolv.conf, knowing that it would be replaced at reboot, but this is what I did, I edited the file and added nameserver 10.0.1.14 and saved it and verified that it was there. After doing that I could ping Google.com (where before without the two dns-* lines i couldn't ping Google.com). But then I knew that I needed to regenerate the resolv.conf file by running sudo resolvconf -u command and when I looked at resolv.conf, my line was gone. So I rebooted the server just to see what would happen and after it came up I could still ping Google.com. So I looked in my resolv.conf file and it had:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 10.0.1.14
nameserver 208.67.220.220
search kingsleylocal.com
So this is what I have learned about setting a static address on Ubuntu 12.04 LTS 64 bit server to get DNS to resolve.
No comments:
Post a Comment