I can't ifdown an interface on Debian 6.0.5:

user@box:/etc/network$ sudo ifdown eth0 && sudo ifup eth0
ifdown: interface eth0 not configured
SIOCADDRT: File exists
Failed to bring up eth0.

user@box:/etc/network$ cat interfaces 
auto lo
iface lo inet loopback

allow-hotplug eth0 
allow-hotplug eth1 

auto eth0
iface eth0 inet static
address 10.0.0.1
netmask 255.255.255.0
gateway 10.0.0.254

auto eth1
iface eth1 inet manual

As requested by marco:

user@box:/etc/network/$ cat /run/network/ifstate 
lo=lo
eth1=eth1
  • 4
    What does /run/network/ifstate contain? – Marco Oct 11 '12 at 16:17
  • 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 :) – jwbensley Oct 11 '12 at 16:35
  • @Marco; This has indeed fixed my problem, if you post this as an answer I can mark it as correct :) – jwbensley Oct 11 '12 at 16:40
up vote 52 down vote accepted

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.

  • 7
    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. – David Parks Apr 4 '13 at 9:15
  • @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. – Marco Apr 4 '13 at 9:23
  • --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! – sanmai Jun 23 '17 at 4:40

ifdown is a high-level program which does a lot of things you might not need. Additionally, it isn't available everywhere. The more portable way might work for you:

$ sudo ifconfig eth0 down

If you then can't ifup it, you likely have some configuration problem. Manually bringing it up with ifconfig eth0 up probably isn't the right thing in that case. On Debian, ifup is a binary executable, so you'd probably have to strace it to figure out where it's getting hung up:

$ sudo strace -e open ifup eth0

That will tell you which files ifup is opening while it works, which might clue you into the problem.

On other systems (e.g. RHEL and derivatives) ifup is a shell script, so it's a lot easier to debug:

# sh -x `which ifup` eth0

Running a shell script with sh -x makes it print every line it runs, so you can trace the execution.

  • A cracking answer, but Marco has found the problem. I did try sudo ifconfig eth0 down && sudo ifconfig eth0 up which would flap the interface up and down but I was trying to manually trigger an if-up script I have been writing and that wasn't doing it. After updating my /etc/network/run/ifstate file, ifdown/up works now. Thanks for your info though! :) – jwbensley Oct 11 '12 at 16:39
  • Forgot to say, great idea with the -x option! Thanks! – jwbensley Oct 11 '12 at 16:53
  • 1
    ifdown is a high-level program which does a lot of thing that you might need. ifconfig eth0 down is more portable and can always be run, but it doesn't perform the cleanup tasks that ifdown might do. – Gilles Oct 11 '12 at 23:12
  • I don't mean to suggest that you use ifconfig all the time, avoiding ifup/down. I suggested it only as a troubleshooting step. As I understand the problem, it turned out to be a result of using ifconfig instead of ifup/down, thereby confusing the high-level mechanisms. But, I didn't know that when I posted my answer. – Warren Young Oct 12 '12 at 0:02

I've seen this before when ethX wasn't properly configured in /etc/network/interfaces. This needs something like:-

auto eth0
   iface eth0 inet dhcp

Even with an improperly configured /etc/network/interfaces file, you can still bring down eth0 with:

$ sudo ip link set eth0 down
  • This is exactly what happened to me. I forgot to append it to auto. Thanks. – Mike Feb 9 '15 at 19:19

For anyone struggling with this problem:

I checked the file ifstate."interface-name" at /run/network.

It was empty so I included "interface-name"(eth0) into ifstate."interface-name" file at /run/network.

Add eth0=eth0 to /run/network/ifstate. This worked for me

What I found helped me is to call the rm command to remove the lock file within /run/network/

Do ls -la and you should see a hidden .ifstate file or something under that name.

Remove that and then try: ifdown && ifup

If you're worried you might break something just make a copy of that file outside the directory and remove the one inside the directory.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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