8

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.

1
  • 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, 2014 at 0:00

1 Answer 1

12

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.

7
  • 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, 2014 at 23:59
  • 2
    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 Jul 19, 2014 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, 2014 at 0:10
  • @Simon Yes! Please, mark it as accepted :) you can also upvote it
    – Lucio
    Jul 19, 2014 at 0:13
  • 1
    By the way, this forum is really, really good - lots of helpful people who don't ridicule us beginners - thanks to everyone involved.
    – Simon
    Jul 19, 2014 at 0:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .