Tuesday, March 18, 2014

How to set permanent IP in Ubuntu ?

Steps :

*) Open the interfaces file :
          sudo vi /etc/network/interfaces

If you are using DHCP you will see the following lines :
          auth eth0
          iface eth0 inet dhcp 

*) To make it static, Change the line iface eth0 inet dhcp to iface eth0 inet static and add the following just below it:

address (IP address that you need to set)
netmask (Default mask which in this case is the default class c subnet)
gateway (Typically your router’s IP address)
network (The network that this machine is running on)

Here is a screenshot of how it should look below :

*) Once you save this file you need to restart your networking service.
       sudo /etc/init.d/networking restart
       sudo service networking restart

Note :
 /etc/init.d/networking restart command is deprecated on new debian and ubuntu, So in such case you can use :
            ifdown eth0 && ifup eth0