Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #script to start/stop hostapd, dnsmasq, add/remove iptables rule
- set -e
- exec 3>&1
- exec 2>&1 >> /tmp/wifi-ap
- function print_help(){
- echo "Start/Stop Software Access Point"
- echo
- echo "Usage `basename $0` options..."
- echo "wifi-ap on to start Software AP"
- echo "wifi-ap off to stop Software AP"
- echo
- echo "log-file - /tmp/wifi-ap"
- echo
- }
- if [ $# = 0 ]; then
- print_help >&3
- exit 0
- fi
- if [ $1 = on ]; then
- ifconfig wlan0 192.168.2.1
- service dnsmasq start
- sysctl net.ipv4.ip_forward=1
- iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
- service hostapd start
- notify-send --expire-time=4000 "Software Access Point" "<b>start</b>"
- exit 0
- fi
- if [ $1 = off ]; then
- service dnsmasq stop
- service hostapd stop
- ifconfig wlan0 192.168.1.4
- sysctl net.ipv4.ip_forward=0
- iptables -D POSTROUTING -t nat -o ppp0 -j MASQUERADE
- notify-send --expire-time=4000 "Software Access Point" "<b>stop</b>"
- exit 0
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement