Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
    address 172.16.61.4
    netmask 255.255.255.192
    nameserver 172.16.61.2
    broadcast 172.16.61.63

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

1 Answer 1

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
nameserver 172.16.61.2

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
1  
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

 
discard

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.