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


sudo ifconfig eth0:1

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.

  • Have you tried nmcli networking off? – Tobias Apr 10 '16 at 16:52
  • Have you tried 'sudo ifconfig eth0 down' command? Do you want to disable it on startup too? Then you have to edit the /etc/rc.local file and include the aforesaid command before the line 'exit 0', save and reboot. Hope it helps. – Arijit Chatterjee Apr 10 '16 at 17:19
  • 1
    Possible duplicate of How do I set an extra IP for an existing interface? – cmks Apr 10 '16 at 18:02
  • "nmcli networking off" -> "Error: Object 'networking' is unknown, try 'nmcli help'." – Ludwig Schulze Apr 10 '16 at 19:28
  • "ifdown eth0" -> "ifdown: interface eth0 not configured" – Ludwig Schulze Apr 10 '16 at 19:29

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.

  • I may be missing something here. Actually I have tried to do what you suggest - add another network configuration for ethernet by clicking on the network manager icon, selecting "edit connections", and set the new connection so that it does not autoconnect. However, I do not see a way to activate this connection when I need it. This connection does not show up in the menu of the network manager icon in unity. – Ludwig Schulze Apr 10 '16 at 20:05
  • @LudwigSchulze You must add it as the correct type ethernet vs. wifi - when I have no ethernet connection at all my ethfix doesn't show up either. – guntbert Apr 10 '16 at 20:21
  • Hmm. My connection with the static ip but no autoconnect lives in the "Ethernet" category, right under "Wired Connection 1" which is my DHCP connection and which set to autoconnect. I just checked if maybe my static ethernet shows up when a network cable is connected, but no, only my dhcp connection shows up in the icon menu and the icon shows the "connection in progress" animation, trying to connect using dhcp, but to no avail, as the special purpose PC with the static IP does not have a DHCP server. – Ludwig Schulze Apr 10 '16 at 20:22
  • @LudwigSchulze just for a test: try nmcli c (on CLI) -- does the connectio show up there? If yes you could try to restart network Manager. – guntbert Apr 10 '16 at 20:26
  • yes nmcli c shows the static connection – Ludwig Schulze Apr 10 '16 at 20:31

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:

       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.
  • No, does not help: ifdown eth0 results in" ifdown: interface eth0 not configured". eth0 does not show up at all in /etc/network/interfaces. That only manages lo. – Ludwig Schulze Apr 10 '16 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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