Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I can't ifdown an interface on a Debian 6.0.5 box;

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

I'm stumped. Any help would be greatly appreciated.

Thank you.

UPDATE

As requested by marco;

user@box:/etc/network/$ cat run/ifstate 
lo=lo
eth1=eth1
share|improve this question
3  
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
add comment

3 Answers

up vote 15 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.

share|improve this answer
1  
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
add comment

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.

share|improve this answer
    
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
    
Yeah, too bad it doesn't work on Debian. I wrote that from a CentOS perspective, then went to try it on a Debian VM and got the legs kicked out from under me and had to rewrite the answer. –  Warren Young Oct 11 '12 at 16:57
    
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
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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