Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two Ubuntu PCs whose network cards connected directly to each other with cross-over cable. I have assigned ip addresses manually to their interfaces using command similar to

 ifconfig eth0 up

The problem is that every time I physically disconnect those PCs, the connection goes down and next time when I connect it back, the IP addresses are lost. Also whatever applications I have bound to those addresses before disconnect needs restarting two. Is there a way to keep network interfaces UP during physical cable disconnect so the apps which create listening sockets on those addresses, would not need to be restarted after re-connect?

share|improve this question
Its not possible for a connection to stay during disconnects. That's just the way Ethernet works. You can ensure that when you reconnect you always have the same IP address: Seppo's answer tells you how to do this but when you disconnect you don't have an IP address. The card may be reporting the same IP address but any open connections will be broken and have to be re-established. – Warren Hill Oct 3 '13 at 16:20
up vote 4 down vote accepted

Edit your /etc/networking/interfaces and add:

iface eth0 inet static

Then eth0 has static ip always.

More info on configuring interfaces with man interfaces

You can also use Network Connections graphical setup tool from your system preferences. You can configure network-manager to use static ip-addresses from there.

share|improve this answer
But will it stay UP during disconnects? Like would the software be able to bind to that ip address, while the cable is not physically plugged in into the network card? – Ma99uS Jun 23 '11 at 12:28
I'm not sure. Can you test it? – Seppo Erviälä Jun 23 '11 at 13:11
I will try it and report back – Ma99uS Jun 23 '11 at 13:16
Yes, that worked. Thank you. – Ma99uS Jun 27 '11 at 12:12

NetworkManager now seems to support an config option to ignore the carrier-state of interfaces and keep them up during disconnects: clarifies how to use the ignore-carrier option.

share|improve this answer

Your Answer


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.