#!/bin/sh
# guest wireless wl0.1 DHCP
killall dnsmasq
sleep 2
echo "interface=wl0.1" >> /etc/dnsmasq.conf
echo "dhcp-range=wl0.1,192.168.2.2,192.168.2.254,255.255.255.0,21600s" >> /etc/dnsmasq.conf
echo "dhcp-option=wl0.1,3,192.168.2.1" >> /etc/dnsmasq.conf
dnsmasq --log-async
sleep 2
# guest wireless assignment
ifconfig wl0.1 192.168.2.1 netmask 255.255.255.0
# guest wireless bridge
ebtables -t broute -I BROUTING -p ipv4 -i wl0.1 -j DROP
ebtables -t broute -I BROUTING -p arp -i wl0.1 -j DROP
# guest wireless firewall. vpn kill switch is in built.
iptables -I INPUT -i wl0.1 -m state --state NEW -j ACCEPT
iptables -I FORWARD -i wl0.1 -o tun11 -j ACCEPT
iptables -t nat -I POSTROUTING -s 192.168.2.0/24 -o tun11 -j MASQUERADE
#optional. block all ports on vpn except: dns(53),http(80),https(443)
iptables -I FORWARD -i wl0.1 -s 192.168.2.0/24 -o tun11 -p tcp -m multiport ! --port 53,80,443 -j DROP
iptables -I FORWARD -i wl0.1 -s 192.168.2.0/24 -o tun11 -p udp -m multiport ! --port 53,443 -j DROP