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.

How to setup static IP address under Ubuntu 14.04 Trusty?

My setting is not working. What special about Ubuntu 14.04 Trusty is that I found it now using the "source-directory" keyword to source multiple files at once (Ref: http://manpages.debian.org/cgi-bin/man.cgi?query=interfaces&apropos=0&sektion=0&manpath=Debian+unstable+sid&format=html&locale=en):

$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

So I prepared my static IP address setting as this:

$ cat /etc/network/interfaces.d/eth
auto eth0
    iface eth0 inet static
    address 192.168.2.100
    netmask 255.255.255.0
    gateway 192.168.2.0
    # add a 2nd ip address
    post-up ip addr add dev eth0 192.168.2.101/24
    pre-down ip addr del dev eth0 192.168.2.101/24

However, it has an extensive delay during boot up. I saw the boot up message saying something like "Bring up Network", then after a long delay later, saying something again like "Waiting for 60 more seconds to bring up Network". After that 60 more seconds delay, the boot up messages start to fly again. However, when the system finally boot, and I check the ip addr output, the second static IP address that I configured is not there.

Am I missing something?

UPDATE:

Thanks everyone for pointing out that my gateway was wrong so I changed it to 192.168.2.1, and the long delay in boot is gone. Now I'm getting into a new problem.

For my Ubuntus prior to 14.04 Trusty, the above change is sufficient to switch from dynamic IP to static IP. However, with my new Ubuntu 14.04 Trusty, the system boots up with no IPv4 addresses:

$ ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:xx:xx:xx:xx:ef  
inet6 addr: fe80::xxx:xxxx:xxxx:98ef/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:1 errors:0 dropped:0 overruns:0 frame:0
TX packets:69 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000 
RX bytes:250 (250.0 B)  TX bytes:11552 (11.5 KB)

It also gives errors when I was trying to bring down the device:

% ifdown eth0
RTNETLINK answers: No such process
RTNETLINK answers: Cannot assign requested address

I am able to bring up the device afterward though, and then ifconfig & ip addr give the correct output. However, the IPv4 address will be gone after a short while.

How to tell network manager that I've switched my eth device from dynamic IP to static IP? (Command-line and file tweaking preferred over GUI tweaking).

This is XUbuntu 14.04. Thanks

UPDATE2:

Use /etc/network/interfaces instead. Details in my own answer.
For automatically setting the /etc/network/interfaces file, take a look here.

share|improve this question
    
I generally don't use network manager..... –  mdpc May 10 at 20:39
    
I have network-manager & network-manager-gnome installed in my Ubuntu 13.10, and my static IP address setup is fine. –  xpt May 10 at 21:07
    
Strange, I am also running 14.04 and static address works (though I haven't configured a second IP). –  user1301428 May 10 at 22:40
    
@user1301428, does your setting have more items? I used to do this, superuser.com/questions/736037/…, but figured from the replies that I can omit many things. Would that be the case, or you are doing some more things than the mere things in my OP? –  xpt May 11 at 1:22
    
My /etc/network/interfaces file only contains the iface, address, netmask, gateway, network, broadcast and dns-nameservers directives –  user1301428 May 11 at 17:49

4 Answers 4

up vote 2 down vote accepted

Ok, I ditched Microsoft and change my household computers and laptops to Ubuntu 14.04 :)

After a week long searching the internet how to get a static ip-address on Ubuntu 14.04 I finally found a way ...

It seems the network-manager is overwriting (or by-passing) my /etc/network/interfaces every single time, I thought of removing it but decided on trying to use it first.

Go to the right upper corner and click the network icon, go down to the bottom and right click edit connections.

This opens network connections and choose the connection to change, click edit and go to IPv4 settings. Choose Method: Manual and then fill in the Address, Netmask and Gateway ... and your desired DNS server.

Just save and your done ... it will change to the given static IP-address on the fly ... even after reboot!!

This might be an old thread, but after a week of searching I updated the 10 first hits in Google ... hope to safe other people some time!!

Take care!

share|improve this answer
    
good to know. thanks. +1 –  xpt Jul 29 at 13:17
    
How do you apply the changes done using the network manager ? –  Sebastien Aug 1 at 13:23

Your gateway is incorrect (gateway 192.168.2.0). This is not a valid IP and you should substitute it with your router's IP address.

share|improve this answer
    
Wow, so fast! I believe you are right, but let me just reboot and test that... –  xpt May 10 at 17:23
    
Address 192.168.2.0 would be valid IP address for /23 CIDR network 192.168.1.0 (netmask 255.255.254.0). Granted, in this case you are right, but this is not universal truth –  mvp May 11 at 7:03
gateway 192.168.2.0

May not be configured to your routers correct gateway.

share|improve this answer

I think I found the answer, having moved the content from /etc/network/interfaces.d/eth into /etc/network/interfaces, and rebooted, it is working now.

cat /etc/network/interfaces.d/eth >> /etc/network/interfaces
rm /etc/network/interfaces.d/eth
service networking restart
reboot

I guess that ifup understand source-directory /etc/network/interfaces.d and can handle it correctly while network manager can't.

share|improve this answer

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.