Script to setup ubuntu as a wireless accesspoint on a bridge mode
- by nixnotwin
I use the following script to make my netbook a full-fledged wireless accesspoint. It creates a bridge with eth0 and wlan0 and starts 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
This script works efficiently. But if I want to revert back to use Network Manager, I cannot do it. The bridge simply cannot be deleted. How can I modify this script so that if I run bridge_script --stop, the bridge gets deleted, network manager starts and interfaces behave as if the machine had a fresh reboot.