Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having some problems configuring a static IP on my ubuntu server. What is the easiest way to configure IP, netmask, nameserver and default gateway on eth0?
I've tried modifying the /etc/network/interfacesfile but the interface goes down after reboot. I need to do this in CLI.

This is what the file looks like (without the comments):

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static

EDIT: It seems to work now. However, nslookup doesn't find any matches at all. Local nslookups on the 2008 server running dns works.

share|improve this question
That's the correct place to do it, perhaps you should include the content of that file in your question. Maybe its just missing something. – ThatGraemeGuy May 17 '12 at 12:12
up vote 1 down vote accepted

The nameserver should be placed in /etc/resolv.conf, exactly as you have it above.

Also, add the domain name used in the local network, to avoid having to use fqdn for lookups:

domain local

Replace local with whatever your local domain is.

share|improve this answer
It's a switched LAN so no gateway should be needed, right? I'm still able to ping when I start the interface again. – Filip Haglund May 17 '12 at 13:00
Sorry @FilipHaglund, I don't follow your question. If you need to access anything outside of the local lan, you need routing. If you need to access the internet, you need a default gateway. Can you post an /sbin/ifconfig -a before and after you bring the interface up, along with a netstat -rn after? – Paul May 17 '12 at 13:08
It's a local network without internet access. Routing table shows eth0 as default gateway and ping works. Nslookup doesn't. – Filip Haglund May 17 '12 at 13:17
Ah right. Your question asks where the default gateway should be configured. I have altered my answer in response to your new information – Paul May 17 '12 at 14:09
Missed your /etc/resolv.conf. I was adding the nameserver to /etc/network/interfaces file. Guess I'm too used to having links formatted like this. It works now though! Thanks! – Filip Haglund May 17 '12 at 15:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.