Can't ifdown eth0 (main interface)

  • I can't ifdown an interface on Debian 6.0.5:

    [email protected]:/etc/network$ sudo ifdown eth0 && sudo ifup eth0
    ifdown: interface eth0 not configured
    SIOCADDRT: File exists
    Failed to bring up eth0.
    [email protected]:/etc/network$ cat interfaces 
    auto lo
    iface lo inet loopback
    allow-hotplug eth0 
    allow-hotplug eth1 
    auto eth0
    iface eth0 inet static
    auto eth1
    iface eth1 inet manual

    As requested by marco:

    [email protected]:/etc/network/$ cat /run/network/ifstate 

    What does `/run/network/ifstate` contain?

    I have updated my question with the contents of this file, eth0 isn't in there. A quick "Google" is telling me the meaning of this file (as I haven't accessed it before), I think I can see where the problem is :)

    @Marco; This has indeed fixed my problem, if you post this as an answer I can mark it as correct :)

  • Marco

    Marco Correct answer

    8 years ago

    Check the contents of the file /run/network/ifstate. ifup and ifdown use this file to note which network interfaces can be brought up and down. Thus, ifup can be easily confused when other networking tools are used to bring up an interface (e.g. ifconfig).

    From man ifup

    The program keeps records of whether network interfaces are up or down. Under exceptional circumstances these records can become inconsistent with the real states of the interfaces. For example, an interface that was brought up using ifup and later deconfigured using ifconfig will still be recorded as up. To fix this you can use the --force option to force ifup or ifdown to run configuration or deconfiguration commands despite what it considers the current state of the interface to be.

    To add to this answer, I had to add `eth0=eth0` to `/run/network/ifstate` to get it to recognize the interface and configure it properly. This answer helped point me to the file, but stopped short of suggesting that addition, which is what solved my similar problem.

    @DavidParks Are you sure the interface is marked as `auto` in `/etc/network/interfaces`? It should appear in `/run/network/ifstate` without the need to manually modify the file.

    `--force` was the answer for me; it turned out `ifup` didn't bring the interface up in the first place because of a failing command in `/etc/network/if-pre-up.d`; lucky me having network at all!

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM