Answers:
尝试禁用“网络小程序”下的无线网络,可从桌面右上角的图标访问该小程序。
注意:网络小程序的图标看起来像一个三角形的楔形。上面的图像指向的是箭头1。如果单击它,应该会看到一个菜单滑出菜单,您可以从该菜单中永久禁用无线功能,箭头2。
从文件中,/etc/network/interfaces
您可以指定NetworkManager不应控制wlan0
界面。为此,只需将此行添加到上述文件中:
iface wlan0 inet manual
然后重新启动NetworkManager:
$ sudo service network-manager restart
我必须执行与此类似的操作,但希望该设备完全不启动。我们已经物理掩盖了基于Linux的设备中的以太网端口,因此它根本不会出现。
我是用udev规则完成的。
当添加具有eno2的ID_NET_NAME_ONBOARD的网络设备时,此udev规则将告诉linux删除pci设备。将其添加到例如/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'"
神奇的环境变量(如ID_NET_NAME_ONBOARD)由udev 在此处设置。我已经从下面那个文件的注释中复制了一些示例。
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
测试规则时,您将需要运行以下命令,以确保所有内容都匹配并且语法正确。
# 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
您可以使用systemd永久禁用网络接口。例如,如果要禁用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)
接下来,一个接一个地拿他们,看看他们做了什么:
$ 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
停止并禁用它们:
$ sudo systemctl stop wpa_supplicant@wlan0.service
$ sudo systemctl disable wpa_supplicant@wlan0.service
wpa_supplicant@wlan0.service
例如,禁用将具有wlan0接口将不会尝试连接到无线网络的效果。