0

eth0 is managed by the network manager icon and connects using dhcp when it detects a network cable.

However, very occasionally I want to connect to some special-purpose computers with static IP addresses using a direct ethernet connection (cross-over). Then I set

sudo ifconfig eth0 10.90.90.91

or

sudo ifconfig eth0:1 10.90.90.91

and can connect to the computer in question.

However, after a minute or so, that eth0 looses that IP address and my connections hang until I repeat the ifconfig step.

Right now I'm using a loop and repeat setting the IP address every 10 seconds.

But I wonder if I can tell the network manager (which I suspect is the culprit) somehow to, right now, not try to manage eth0 until I need it again to do it.

Edit: The question How do I set an extra IP for an existing interface? differs from mine. That question wants to perpetuate the setting across reboots. I'm not interested in that. I only want to have that fixed IP address for eth0 very occasionally. Usually the dhcp procedure is ok for me. Only sometimes I want it to back off.

2 Answers2

1

Use ifdown (and ifup). See man ifdown. If you don't want use /etc/network/interfaces, after ifdown you can use ifconfig to configure by hand. From man ifdown:

DESCRIPTION
       The   ifup   and   ifdown  commands  may  be  used  to  configure  (or,
       respectively,  deconfigure)  network  interfaces  based  on   interface
       definitions  in  the file /etc/network/interfaces.  ifquery command may
       be used to parse interfaces configuration.
waltinator
  • 37,856
1

If I understand correctly you want sometimes a different configuration for your network and you want to use Network Manager - I presume GUI.

So you open the network manager, add another connection (call it static address or so). Now configure this connection with the settings you want, don't set Automatically connect to this network..

screenshot general enter image description here

Whenever you need this special setting just select it from the Network Manager menu.

guntbert
  • 13,475