How to permanently disable a network interface?

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

  • How to disable built-in wifi and use only USB wifi card?

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