Change Ubuntu Server from DHCP to Static
added by Johan 1/13/13
After installing Ubuntu Server 12.04, it has set your server to use DHCP. You will most likely want to change it to use a static/fixed IP address.
We are going to edit the /etc/network/interfaces file. I use nano, but you can choose a different editor:
1. sudo su
enter your password
2. nano /etc/network/interfaces
For the primary interface, which is usually eth0, you will see these lines:
auto eth0
iface eth0 inet dhcp
As you can see, it’s using DHCP right now. We are going to change dhcp to static, and then there are a number of options that should be added below it.
Obviously you’d customize this to your network.
auto eth0
iface eth0 inet static
address 192.168.0.5
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.7 192.168.0.6
3. Save the file
Ctrl-X then Y
4. After saving the above file, restart the network with the following command:
service networking restart
Important: If running inside a virtual machine make SURE to change the interface from NAT to Bridged in the VM settings.