How To Set A Static IP Address On A Ubuntu Server

Depending on your network, your IP address, subnet, gateway ..etc setting will or could be different. Most home networks use a class C network with one subnet, so these settings could be applied in that case. Check your current IP address to get an idea what to use.

Lets get into it.

Change directories to /etc/networking/ by using the following command.

cd /etc/network/



cd /etc/network/



We are now going to edit the file “interfaces”. If you are new to editing files in the command like I would suggest using nano text editor instead of vi. In this example we will be using nano to make things easier.

sudo nano interfaces



sudo nano interfaces


Default Interfaces File



Change dhcp to static and add the following lines adjusting the address to fit your network settings.






Bare Bones needed Config



You can also add some additional information if wanted such as network address and broadcast address.



A few additional options you can add



After making your changes hit CTRL + x

Select “Y” to save the file



To exit Nano hit CTRL + X - Enter Y to save the file



Leave the file name the same and just hit enter to overwrite the old file.



Overwrite old interfaces file



Now that we made the changes to the interfaces file we just need to restart networking. Enter the following command:

sudo /etc/init.d/networking restart



sudo /etc/init.d/networking restart



Restart Sucessful



To test to see if the new IP address type the following command:







You can see the new IP address has been applied for interface eth0. Now lets run one more test and ping Google to make sure we have the correct network configuration.






Press CTRL + c to stop the ping

It looks like all packets made it to there destination

We should be all set with are new static IP address.

If you enjoyed this post, please share it on your favorite social network by clicking on the “Share / Save” bar below.