How to assign a static IP in Ubuntu OS?


First of all, you want to run the following command in CLI mode: ifconfig. “ifconfig” will show you all the interfaces on your server. You are expected to see a loopback interface & either a single or multiple Ethernet interfaces depending on the server specs. By default, the Ethernet interface or interfaces are set to DHCP. Once you have figured out which Ethernet interface you want to change the IP address on. Go ahead & enter the VI editor mode by typing in the following CLI  mode command:

sudo vi /etc/network/interfaces

Now edit the interface as follows (the below-mentioned is just an example & you would obviously have to replace these parameters based on your local subnet 🙂):

auto eth0
iface eth0 inet static
address 10.10.10.1
netmask 255.255.255.0
network 10.10.10.0
broadcast 10.10.10.255
gateway 10.10.10.1

Once you are done making the changes. Type in “:wq” to save (write) the file & quit the VI editor. Now verify the change by typing in “ifconfig“.

In some cases you may have to re-initialize the networking module. You can do so by typing in the following command:

sudo /etc/init.d/networking restart

Congrats!!! You have now successfully assigned a static IP to an Ethernet interface.

, ,

  1. No comments yet.
(will not be published)


  1. No trackbacks yet.