How to convert my IP From Dynamic to static in Ubuntu

Question: How   to  convert   my  ip  adress  in ubuntu  from Dynamic  to  static  ?linux-logo

Answer:

1- First edit network interface using your favorite text editor :

sudo vi /etc/network/interfaces

Normally you  are  using   eth0  for  card  ethernet  you will see  some  thing  like  this :

auto eth0
iface eth0 inet dhcp

Remove line 2 and add:

auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

save a and  exit

192.168.1.100 suppose  to be  your  static  IP you can change it  to  the IP   you  want

192.168.1.1 is  the  router  IP

Now we’ll need to add in the DNS settings by editing the resolv.conf file:

sudo vi /etc/resolv.conf

and  add  the 2 ip adresss  of  your  DNS servers  ( internet provider)

3- remove dhcp client

In terminal, type the following command:

sudo apt-get remove dhcp-client

4- Restart network

sudo /etc/init.d/networking restart

Now you shloud have a static IP instead of dynamic one.

Is done.