59

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 
3
  • 4
    What does /run/network/ifstate contain? Commented Oct 11, 2012 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 :) Commented Oct 11, 2012 at 16:35
  • @Marco; This has indeed fixed my problem, if you post this as an answer I can mark it as correct :) Commented Oct 11, 2012 at 16:40

6 Answers 6

62

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.

3
  • 10
    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. Commented Apr 4, 2013 at 9:15
  • 1
    @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. Commented Apr 4, 2013 at 9:23
  • 3
    --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! Commented Jun 23, 2017 at 4:40
35

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.

5
  • 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! :) Commented Oct 11, 2012 at 16:39
  • Forgot to say, great idea with the -x option! Thanks! Commented Oct 11, 2012 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. Commented Oct 11, 2012 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. Commented Oct 12, 2012 at 0:02
  • Possibly obvious, but don't do what I just did which was sudo ifconfig eth0 down on a remote machine 😅. Make sure you do sudo ifconfig eth0 down && sudo ifconfig eth0 up Commented Jul 20, 2022 at 1:49
24

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 
1
  • This is exactly what happened to me. I forgot to append it to auto. Thanks. Commented Feb 9, 2015 at 19:19
4

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.

2

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

1

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.