diff options
Diffstat (limited to 'viensamoi/create_ap.sh')
-rwxr-xr-x | viensamoi/create_ap.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/viensamoi/create_ap.sh b/viensamoi/create_ap.sh new file mode 100755 index 0000000..28f595c --- /dev/null +++ b/viensamoi/create_ap.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +if [[ $# -ne 3 ]]; then +#if [[ $# -ne 4 ]]; then + echo "usage: $0 iface ssid bssid" + #echo "usage: $0 iface ssid bssid ip" + exit 1 +fi + +IFACE=$1 +SSID=$2 +BSSID=$3 +#IP=$4 +IP=172.16.0.1 # fixed for now, keep coherent with dnsmasq.conf + +sudo tmux new-session -d -s create_ap +sudo tmux select-window -t create_ap:0 + +echo "[+] Killing old daemons" +sudo pkill -f 'hostapd ./hostapd.conf' +sudo pkill -f 'dnsmasq -q' + +echo "[+] Setting $IFACE bssid to $BSSID" +sudo ifconfig $IFACE down +sudo ifconfig $IFACE hw ether $BSSID + +echo "[+] Configuring hostapd.conf" +sed -i "s/^interface=.*/interface=$IFACE/" ./hostapd.conf +sed -i "s/^ssid=.*/ssid=$SSID/" ./hostapd.conf + +echo "[+] Starting hostapd" +sudo tmux split-window -h -t create_ap "sudo hostapd ./hostapd.conf" + +echo "[+] Setting $IFACE IP to $IP" +sudo ifconfig $IFACE $IP up + +echo "[+] Starting DHCP and DNS" +sudo tmux split-window -v -t create_ap "sudo dnsmasq -d -i $IFACE -C ./dnsmasq.conf" + +echo "[+] Configuring iptables" +sudo iptables -I INPUT -i $IFACE -p udp --dport 67:68 --sport 67:68 -j ACCEPT + +echo "[+] All set ! Waiting..." +sleep 1 +sudo tmux select-pane -L -t create_ap +sudo tmux send-keys -t create_ap:0 "ifconfig $IFACE"
+sudo tmux send-keys -t create_ap:0 "iwconfig $IFACE"
+sudo tmux send-keys -t create_ap:0 "route -n"
+ +sudo tmux attach-session -t create_ap |