how to configure a static IP address on Ubuntu server
From Sharkysoft Wiki
After a fresh install of Ubuntu server, your network interface will have probably been automatically configured using DHCP. If you're setting up a server, however, you'll want a static IP address. This article shows you how to reconfigure your network interface to use a static IP address.
To configure a static IP address, edit the file /etc/network/interfaces.
Look for the definition of the primary interface, which is usually called eth0. It might look like this:
# The primary network interface auto eth0 iface eth0 inet dhcp
Update the token "dhcp" with "static" and add some lines to fully specify the static configuration, so that the definition looks like this:
# The primary network interface auto eth0 iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1
For more information on other options available with this file, consult the man page by issuing the command,
man interfaces
You may have noticed that the interface definition given above does not specify any DNS servers. These are defined in a separate file at /etc/resolv.conf. If DHCP was working correctly before you started, then you may be able to just keep the name servers that are already listed. However, you should check this file just in case, and edit it if necessary. In particular, make sure you have at least one nameserver listed. It is also a good idea to set your domain, as follows:
nameserver 198.60.22.2 domain sharkysoft.com
When you are finished configuring both files, restart your network by issuing the command,
/etc/init.d/networking restart
Finally, run ifconfig to verify that everything has been set correctly.
