Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to set up my machine with a static IP address. I've done it before and it worked.

It's been a long time so, once again, I researched how to do it before starting. It looked pretty familiar and I could remember the process from before ... so I got started ...

I should mention that this is a new installation. The only thing I did before attempting this was to do an update and install ssh.

The first thing that I thought was odd was the contents of /etc/network/interfaces. It looked like this:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

Where's the stuff I usually find (and the walk through pages all seemed indicate that I would find) for eth0? I was expecting to see:

auto eth0
iface eth0 inet dhcp

Funny thing is, it did pick up an IP address - 192.169.1.100 - which is a bit odd because IPs are usually assigned on a sequential basis and I would have expected it to pick up 192.168.1.7 because this was the next available IP.

Anyway, all this oddness aside, I ploughed on. I added the following to /etc/network/interfaces

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

Then the next dose of oddness ... I issued the following command: /etc/init.d/networking restart ... nothing happened. No error messages, nothing at all. So, I tried this: service networking restart ... this is what happened:

stop: Job failed while stopping
start: Job is already running: networking

So I rebooted. The network configuration looked just great. I could ssh into the machine from inside my internal network. At this moment I thought I'd done it and I could forget the odd stuff. But no, the next thing I did was run apt-get update ... it failed ... I tried to ping a couple of websites and nothing would resolve so I'm guessing it's not finding a DNS server.

But it's just a guess and it doesn't help me because I don't know what to try next.

share|improve this question
    
Thanks user68186 - I've taken that approach before but it introduced another set of problems (that I do understand for a change!) that I want to avoid this time. –  Simon Jul 19 at 0:00

1 Answer 1

up vote 4 down vote accepted

The default /etc/network/interfaces file only contains the loopback interface definition because desktop versions of Ubuntu use the NetworkManager service instead.

Your current configuration is missing a dns-nameservers specification, so it cannot resolve names to IP addresses.

You could add one or more dns-nameservers, however unless you have a particular reason to use the networking service, it would probably be better to revert your changes and then set up a static interface via NetworkManager's nm-applet (from the menu bar) or by invoking nm-connection-editor from a terminal - navigate to the IPV4 Settings tab and change the drop-down Method: from DHCP to Manual and then enter your desired network parameters there.

share|improve this answer
    
Ah - now this makes sense - when I did all this before I didn't have a gui installed - this time I installed the lot. Right, I'm going to try adding a dns-nameserver just because I want to see this through but I'll probably re-install without the gui. This machine is inteded to be a file server for a small network of windows pcs and macs. Is there any reason to use or not to use a gui for this role? I am more comfortable with command line stuff for this kind of thing but I thought that the gui might help with some other stuff that I might do on the machine. Thanks steeldriver –  Simon Jul 18 at 23:59
    
If you're comfortable administering everything via CLI that's fine. FYI the keyword in the /etc/network/interfaces file needs to be dns-nameservers (plural) even if you only specify a single one e.g. dns-nameservers 192.168.1.1 or dns-nameservers 8.8.8.8 8.8.4.4 –  steeldriver Jul 19 at 0:04
    
Excellent - that worked - I simply added this: dns-nameservers 8.8.8.8, restarted and it worked. I am a very happy, I can go to bed now! :) I will get shot of the gui tomorrow. Thank you so much steeldriver. By the way, is it possible to mark this as solved? I've looked for a button/link but, either I'm too tired to see it or it's not there. –  Simon Jul 19 at 0:10
    
@Simon Yes! Please, mark it as accepted :) you can also upvote it –  Lucio Jul 19 at 0:13
    
Thanks Lucio, I have accepted it. It seems I can't upvote it because I don't have enough reputation - you should ask our local rozzers (police if you're not English), they'd tell you differently! :) –  Simon Jul 19 at 0:17

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.