Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 192.168.2.1 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 adresses before disconnect needs restarting two. Is there a way to keep networ 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

1 Answer

up vote 2 down vote accepted

Edit your /etc/networking/interfaces and add:

iface eth0 inet static
    address 192.168.2.1
    netmask 255.255.255.0

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

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.