Thursday, August 16, 2012

How to edit network settings manually in Ubuntu Server 12.04 (Precise)

SkyHi @ Thursday, August 16, 2012

Changing network settings in new versions of Ubuntu (don’t know when exactly this new methodology started) like Ubuntu 12.04 Precise Server Edition, has a major difference from the old methodology.
The major change is that you no longer need to edit “/etc/resolv.conf”, and if you try to, your settings will be lost or overwritten once you reboot.
All what you need to change if you want to apply a static address (which is the case in almost all server installations) is the “/etc/network/interfaces” file.
For example:
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.1.2
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.1.255
        gateway 192.168.1.1

dns-nameservers 75.75.75.75, 75.75.76.76
dns-search local
dns-domain local.domain

You will notice that everything is the same, except the last line which used to be added to the /etc/resolv.conf directly before. With this new methodology the “resolvconf” utility will automatically read the “dns-nameservers” one by one (separated by a space) and will append them to the “etc/resolv.conf” file.
After that to apply your changes, you can just do “sudo /etc/init.d/networking restart” or simply reboot your machine if you wish.