Disable network adaptor eth0 on Debian

10

1

Once upon a time, I used ifdown eth0 to down a network adaptor. It has been years since I've been able to get this to work, basically since I've been on Ubuntu/Debian.

I get this:

$ sudo ifdown eth0
ifdown: interface eth0 not configured

If I run ifconfig, I get:

eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx  
          inet addr:192.168.20.50  Bcast:192.168.21.255  Mask:255.255.254.0
          inet6 addr: fe80::6e3b:e5ff:fe36:2ee/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1205280 errors:0 dropped:502 overruns:0 frame:0
          TX packets:34930 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:165685286 (165.6 MB)  TX bytes:5754120 (5.7 MB)
          Interrupt:20 Memory:f7f00000-f7f20000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:9146 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9146 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:734342 (734.3 KB)  TX bytes:734342 (734.3 KB)

I've googled to find out how to do this and everything I can find says run ifdown eth0. How do I stop the network adaptor on Debian/Ubuntu boxes?

Thom

Posted 2013-12-31T12:04:22.070

Reputation: 337

Answers

14

I am facing the same issue on Debian. I don't know the exact cause, however, it is working with sudo ifconfig eth0 down for me.

Edit: Thanks to @kostix for his annotations. I haven't concerned myself with the problem in much detail since I use it to temporarily bring down the interface. If you want to permanently bring it down, ifdown is the way to go. For this to work, you will need to add the line eth0=eth0 to /run/network/ifstate and the lines auto eth0 and iface eth0 inet dhcp to /etc/network/interfaces.

Tim Zimmermann

Posted 2013-12-31T12:04:22.070

Reputation: 331

Captain Obvious here, don't try this in the cloud. – John Lehmann – 2015-12-09T13:09:27.060

This just brings the adapter down on the physical layer (i.e. as far as the kernel network stack is concerned), and this has nothing to do with the userland layer supposed to manage the adapter. Please see my answer -- may be you'll be able to join efforts with the OP to figure out which subsystem manages your network. – kostix – 2013-12-31T12:19:04.847

OK, this did it. I didn't try this before because, on Redhat, ifdown ran ifconfig so I assumed the same for Debian. Silly me. Thanks for this. WTF? – Thom – 2013-12-31T12:20:39.823

@Thom, the problem is that the next time you boot eth0 will most likely be up again. – kostix – 2013-12-31T12:21:13.603

@Thom, as to WTF... ;-) The kernel is (almost) the same across the distros but the userland tools are not. Well, nm and wicd are the same across the distros, but the "traditional" low-level stuff is not. – kostix – 2013-12-31T12:23:14.550

@kostix That's fine. Just wanted to disable a bit for testing. Since it's a VirtualBox it's hard to unplug the network cable. :) Also, I understand about the tools, but the Debian docs say to use ifdown. That's why WTF? – Thom – 2013-12-31T12:52:59.227

@Thom, as per the docs, a call to VBoxManage modifyvm your_vm_name --cableconnected 1 off should do the trick. That's only if you're running w/o the GUI front-end, otherwise it could be done right from the main menu of the window showing the guest's console.

– kostix – 2013-12-31T12:58:55.720

@kostix Looked at the GUI and the checkbox for enable this adaptor was disabled, so I couldn't disable it that way. Didn't look for a command prompt option. Thanks for the info, though. – Thom – 2013-12-31T14:29:22.693

13

if ifconfig isn't available on your distro, it means it is replaced by the ip command. In this case, the solution would be ip link set eth0 down

Nicolas Guérinet

Posted 2013-12-31T12:04:22.070

Reputation: 231

2

There's no definitive answer as there might be several ways to manage networking in Debian. I'm aware of at least three:

  • The "traditional" approach, using /sbin/ifup, /sbin/ifdown and /etc/init.d/networking, all using the /etc/network/interfaces configuration file. These are provided by the ifupdown package.

    Since ifdown knows nothing about the adapter, I reckon another way is used to manage the network.

    I'm also aware about a package which is beleived to be a drop-in replacement for ifupdown, netscript, but since it uses the same means to manage adapters this is supposedly also not your case.

  • NetworkManager
  • Wicd

Supposedly you have to work out which one is instanned and work from there. Both nm and wicd usually are configured using GUI tools (and usually via applets starting along with your DE). nm has a command line tool, called nm-cli. Not sure about wicd.

If you did a simple installation and selected the "Desktop" task then I beleive (though not sure) you've got NetworkManager installed.

kostix

Posted 2013-12-31T12:04:22.070

Reputation: 2 435

1

interface eth0 not configured

litteraly means

not configured in the /run/network/ifstate file

ifupdown commands have an hysteresis: once you activate an interface with ifup, it is stored in /run/network/ifstate that you've activated it.

ifup eth0
cat /run/network/ifstate
eth0=eth0
(+other interfaces)

ifdown eth0
cat /run/network/ifstate
(+other interfaces)

The state will be saved even if the operation failed (mainly because /etc/network/interfaces is not writen correctly). My main solution till now is to manually edit /run/network/ifstate to act as is eth0 were up and then to turn it down:

nano /run/network/ifstate
eth0=eth0

ifdown eth0

Then you can start again with clean setup.

koyaaniqatsi

Posted 2013-12-31T12:04:22.070

Reputation: 11