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.

Lucio
  • 18,648
  • 31
  • 107
  • 190
Simon
  • 303
  • 3
  • 4
  • 13
  • 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 '14 at 00:00

1 Answers1

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.

steeldriver
  • 131,985
  • 21
  • 239
  • 326
  • 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 '14 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` – steeldriver Jul 19 '14 at 00: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 '14 at 00:10
  • @Simon Yes! Please, [mark it as accepted](http://meta.stackexchange.com/q/5234) :) you can also upvote it – Lucio Jul 19 '14 at 00: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 '14 at 00:17
  • 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 '14 at 00:20
  • Seriously, applying the same configuration on a windows machine to see if it works because it is more stable makes Ubuntu a disgrace. – DimiDak Jan 21 '19 at 14:28