Home » Networking » Setting up a static IP address in Ubuntu

Setting up a static IP address in Ubuntu

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 (IP address of what you want your Ubuntu machine to be)
(Default mask which in this case is the default class c subnet)
(Typically your router’s IP address)
(The network that this machine is running on)
 (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 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 or you can easily swap 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.

About Tyler Bailey

Tyler Bailey is a university student who owns and runs draalin.com. Follow me on