Static IP for Ethernet in Ubuntu


Network Manager in Gnome/Ubuntu helps a lot if you are using dynamic IP (DHCP) with your Ethernet interface, but all of suddens, it becomes an obstracle when a static IP is required on Ethernet. Googling around, I found that we can

1) Remove Network Manager (sudo apt-get remove network-manager).

2) Change /etc/network/interfaces so that your interface becomes static ip.

auto eth0
iface eth0 inet static

3) Now restart your network (sudo /etc/init.d/networking restart).

4) At this point, you should have ethernet interface with static IP (, but you will definitely having problem with say Wireless which many (e.g. me) like to have a software to handle configuration automatically. So you will need to re-install Network Manager. (sudo apt-get install network-manager).

5) Now you should have both ethernet and wireless working. Ethernet will NOT be managed by Network Manager though.

6) My next problem was with DNS, say when you stop using Wireless and switch to Ethernet, your ethernet will be up with the static IP but most of the time your DNS will not work (Network Manager and DHCP work together to put DNS server in place), so you will either have to edit the /etc/resolv.conf manually or use ‘resolvconf’ package which allows you to place ‘dns-nameserver xx.xx.xx.xx’ in your /etc/network/interfaces.

7) I do not like to have to many packages installed (I already have a lot installed), so the easiest thing for me is to add a file say ‘dns4eth’ setup with simple content

echo 'nameserver yy.yy.yy.yy' >> /etc/resolv.conf

Simple enough for me that everytime I restart network (sudo /etc/init.d/networking restart) the name server entry will be added to /etc/resolv.conf instead of having to edit by hand. Dirty, yes, because multiple networking restarts will add additional lines into the /etc/resolv.conf file. Do not forget to ‘chmod +x ‘ to your ‘dns4eth’ file.

There are a lot of room to improve, I know, but I am very lazy!

Powered by Qumana


No Responses Yet to “Static IP for Ethernet in Ubuntu”

  1. Leave a Comment

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: