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


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

save a and  exit suppose  to be  your  static  IP you can change it  to  the IP   you  want 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.

  • Freak Andelle

    this is risky business if you ask me. why not show ppl how to do this using a gui like gnome network-manager? als, can you point out why it’s necessary to remove dhcp-client? ppl may need it again in the future and will have forgotten all about the fact that is has been removed…

  • shaga

    i think GUI from network manager is more easy and comfortable in ubuntu.

  • mm

    is good to speak about gui, but if you a re using Server , you should do it on this way

  • Gnoll110

    Setting IP addresses this way for Ubuntu will work, up to 11.10.

    From 12.04 (LTS), it changes. This won’t work as resolv.conf is now a generated file, any change make to it will get overwritten.

  • Jacob Rantor

    Gnoll is right here. To do this graphically, which is the way Ubuntu is trying to push you…. check these instructions

  • Pingback: how to convert ip from dynamic to static in ubuntu? | Webammer()