22

I've brought down a network interface with ifconfig wlan0 down, but every few hours or so, the wlan0 interface comes back up and I can't figure out why.

I don't restart the machine, never changed /etc/network/interface. I guess my question is, how would I go about just "permanently" disabling wlan0. Do I use /etc/network/interface? I already have ifconfig wlan0 down in my rc.local.

31

Method #1 - from NetworkManager's Applet

Try disabling the wireless networking under the Network Applet that's accessible from under the icons in the upper right of your desktop.

                                                    ss #!

NOTE: The networking applet's icon looks like a triangle wedge. The image above is pointing to is as arrow #1. If you click it you should see a menu slide out from where you can disable wireless permanently, arrow #2.

Method #2 - /etc/network/interfaces

From the file /etc/network/interfaces you can specify that NetworkManager shouldn't control the wlan0 interface. To do so simply add this line to the above mentioned file:

iface wlan0 inet manual

Then restart NetworkManager:

$ sudo service network-manager restart

References

  • 1
    Method 1 only works if you have only one wifi card... – xuhdev Jan 8 '15 at 22:55
0

I had to do something similar to this but wanted the device to not come up at all. We have physically covered up an ethernet port in a linux based device and so it shouldn't appear at all.

I did this with udev rules.

This udev rule will tell linux to remove the pci device when a network device which has the ID_NET_NAME_ONBOARD of eno2 is added. Add it to e.g. /etc/udev/rules.d/90-disable-eno2.rules.

ACTION=="add", SUBSYSTEM=="net", ENV{ID_NET_NAME_ONBOARD}=="eno2", RUN+="/bin/sh -c 'echo 1 > /sys$DEVPATH/device/remove'"

The magic environment variables like ID_NET_NAME_ONBOARD are set by udev here. I have copied some examples from the comment in that file below.

PCI Ethernet card with firmware index "1":
    ID_NET_NAME_ONBOARD=eno1
    ID_NET_NAME_ONBOARD_LABEL=Ethernet Port 1

PCI Ethernet card in hotplug slot with firmware index number:
    /sys/devices/pci0000:00/0000:00:1c.3/0000:05:00.0/net/ens1
    ID_NET_NAME_MAC=enx000000000466
    ID_NET_NAME_PATH=enp5s0
    ID_NET_NAME_SLOT=ens1

PCI Ethernet multi-function card with 2 ports:
    /sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.0/net/enp2s0f0
    ID_NET_NAME_MAC=enx78e7d1ea46da
    ID_NET_NAME_PATH=enp2s0f0
    /sys/devices/pci0000:00/0000:00:1c.0/0000:02:00.1/net/enp2s0f1
    ID_NET_NAME_MAC=enx78e7d1ea46dc
    ID_NET_NAME_PATH=enp2s0f1

PCI wlan card:
    /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0/net/wlp3s0
    ID_NET_NAME_MAC=wlx0024d7e31130
    ID_NET_NAME_PATH=wlp3s0

USB built-in 3G modem:
    /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.6/net/wwp0s29u1u4i6
    ID_NET_NAME_MAC=wwx028037ec0200
    ID_NET_NAME_PATH=wwp0s29u1u4i6

USB Android phone:
    /sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0/net/enp0s29u1u2
    ID_NET_NAME_MAC=enxd626b3450fb5
    ID_NET_NAME_PATH=enp0s29u1u2

s390 grouped CCW interface:
    /sys/devices/css0/0.0.0007/0.0.f5f0/group_device/net/encf5f0
    ID_NET_NAME_MAC=enx026d3c00000a
    ID_NET_NAME_PATH=encf5f0

When testing your rules you will need to run a command like the following to make sure everything is matching and syntax is correct.

# Find the path marked "P" with this command.
udevadm info --path=/sys/class/net/eno2

# Test with this command with the path from above
udevadm test --action="add" /devices/pci0000:00/0000:00:1c.4/0000:03:00.0/net/eno2 2>&1 | less
0

You can permanently disable a network interface using systemd. For example if you want to disable wlan0:

$ systemctl | grep wlan0
sys-devices-platform-soc-XXX.auto-net-wlan0.device loaded active plugged   /sys/devices/platform/soc/XXX.auto/net/wlan0
sys-subsystem-net-devices-wlan0.device             loaded active plugged   /sys/subsystem/net/devices/wlan0                                                                     
wpa_supplicant@wlan0.service                       loaded active running   WPA supplicant daemon (interface-specific version)                                                   

Next take them one by one, check out what they do:

$ systemctl status wpa_supplicant@wlan0.service
● wpa_supplicant@wlan0.service - WPA supplicant daemon (interface-specific version)
   Loaded: loaded (/lib/systemd/system/wpa_supplicant@.service; disabled; vendor preset: enabled)
   Active: active

Stop and disable them:

$ sudo systemctl stop wpa_supplicant@wlan0.service
$ sudo systemctl disable wpa_supplicant@wlan0.service

Disabling wpa_supplicant@wlan0.service for example will have the effect that the wlan0 interface will not attempt to connect to the wireless network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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