如何在Ubuntu上使用网络管理器停止无线AP主机?

我使用以下脚本使我的上网本成为一个成熟的无线接入点。 它创建了一个eth0和wlan0的桥梁并启动hostapd

 #!/bin/bash service network-manager stop ifconfig eth0 0.0.0.0 #remove IP from eth0 ifconfig eth0 up #ensure the interface is up ifconfig wlan0 0.0.0.0 #remove IP from eth1 ifconfig wlan0 up #ensure the interface is up brctl addbr br0 #create br0 node hostapd -d /etc/hostapd/hostapd.conf > /var/log/hostapd.log & sleep 5 brctl addif br0 eth0 #add eth0 to bridge br0 brctl addif br0 wlan0 #add wlan0 to bridge br0 ifconfig br0 192.168.1.15 netmask 255.255.255.0 #ip for bridge ifconfig br0 up #bring up interface route add default gw 192.168.1.1 # gateway 

这个脚本有效地工作。 但如果我想恢复使用网络管理器,我不能这样做。 这座桥根本无法删除。 如何修改此脚本,以便在运行bridge_script --stop ,桥接器被删除,网络管理器启动,接口的行为就像机器重新启动一样。

您必须先删除vbridge中的接口,然后才能将其删除。 这些命令应该这样做:

 killall hostapd brctl delif br0 eth0 brctl delif br0 wlan0 ifconfig br0 down brctl delbr br0 service networking restart