Setting up a static IP address in Ubuntu is very easy!
Before getting started though I recommend doing this at the terminal itself or be within a close proximity of it.
So that if you do make an error and lose connectivity you can revert the changes easily!
Note that when setting up a static IP you should first review your network settings.
With that said lets get started.
In Ubuntu by default your /etc/network/interfaces configuration file will look like the following below.
sudo vi /etc/network/interfaces
For our example lets say we want configure our network configuration to the following (This should work on most default networks, especially home networks)
Change the line iface eth0 inet dhcp to iface eth0 inet static and add the following just below it:
address 192.168.1.100 (IP address of what you want your Ubuntu machine to be)
netmask 255.255.255.0 (Default mask which in this case is the default class c subnet)
gateway 192.168.1.1 (Typically your router’s IP address)
network 192.168.1.0 (The network that this machine is running on)
broadcast 192.168.1.255 (A message that is sent to all out network-attached hosts to essentially find a specific address. You also receive them from other hosts)
dns-nameservers 192.168.1.1 (DNS or Domain Name Server used for responding to queries when you are searching for a website)
Alternatively, for your dns-nameservers some people prefer to use Google’s Public DNS which is 126.96.36.199 or 188.8.131.52 you can easily swap 192.168.1.1 to one of Googles. You can find more information regarding Google Public DNS here.
Here is a screenshot of how it should look below.
Once you save this file you should restart your networking service.
sudo /etc/init.d/networking restart
sudo service networking restart
As you can see setting up a static IP address in Ubuntu is pretty straight forward!
If you have any issues setting up a static IP please comment here or make a post on our forums.