Set a Static IP Address on Ubuntu and Debian via the Terminal


This tutorial will cover the steps required to setup your Ubuntu or Debian machine with a static IP Address via the terminal.


In order to follow this tutorial, you will need the following

  • Ubuntu or any other Debian based machine
  • Sudo Permissions

Changing your IP

When using a server a server a lot it is always a good idea to give it a static IP address so we know where to look for it on another machine. We do this by editing our network config file by typing:

sudo nano /etc/network/interfaces

When you open this file, it should look like as follows:

When you open this file, you will first need to delete the following lines:

allow-hotplug eth0
iface eth0 inet dhcp

You will need to remove the two lines and replace with the following lines. (I will be adding my network configuration so

auto eth0
iface eth0 inet static

Make sure that the one you enter fits your network setup and that the information is available on your network). When you have done this, you will need to save the file (With Ctrl + O) and exit the file (With Ctrl + X)
The next thing we need to do is set the DNS Servers. We do this by editing the following folder:

sudo nano /etc/resolvconf/resolv.conf.d/base

This file should be blank. You will need to add the following content.


Now, I would recommend rebooting so that changes can be taken in to affect. When you log back in, you can run the following to view your network information.