3

I just installed 12.04 Server. After my first login, I saw the IP and it is dynamic (I guess). I tried to change it by sudo vi /etc/network/interface but this file is blank.

Can anyone help here?

3 Answers 3

5

You typed:

sudo vi /etc/network/interface

You should have typed this:

sudo vi /etc/network/interfaces 

You forgot the s.

2

Ubuntu uses Network Manager to manage the network configuration.

Run nm-connection-editor to set a static IP.

1

Adapted from: Create a Static IP from the Command Line


Basically, steps needed are:

Find out you current settings:

ifconfig eth0

Edit /etc/network/interfaces to meet your requirements.

Look for these two line:

auto eth0
iface eth0 inet dhcp

Change them to instead be: (example IP addresses)

auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
    address 192.168.0.130
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1
    dns-nameservers 192.168.0.1

Then re-start your server.

It should now be using: 192.168.0.130

3
  • 2
    12.04 also needs dns-nameservers 192.168.0.x as they changed how resolv.conf works. Oct 5, 2012 at 11:11
  • Sorry, I cribbed from my old notes for 10.04 LTS server.
    – david6
    Oct 5, 2012 at 12:52
  • ifconfig is kind of obsolete now
    – Themelis
    Jun 26, 2020 at 13:24

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