Last active
June 19, 2023 19:37
-
-
Save sergeygalkin/861d87d01657eb9f8e673ddb67e52421 to your computer and use it in GitHub Desktop.
Easy wifi AP in linux with TP-Link Archer T2U PLU
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Based on 2357:0120 TP-Link Archer T2U PLUS [RTL8821AU] | |
# wlx3460f9641ca2 is usb wifi | |
export WIFI_INT=wlx3460f9641ca2 | |
export HOME_NETWORK_1="10.11.11.0/24" | |
export HOME_NETWORK_2="10.12.12.0/24" | |
export WIFI_NAME="My WiFi" | |
sudo echo 1 > /proc/sys/net/ipv4/ip_forward | |
sudo iw dev ${WIFI_INT} set txpower fixed 30mBm | |
sudo airmon-ng start ${WIFI_INT} | |
sudo killall airbase-ng | |
sleep 5 | |
tmux new-session -d -s wifi sudo airbase-ng -e "${WIFI_NAME}" -c 13 ${WIFI_INT} | |
sleep 5 | |
echo "Use 'tmux att -t wifi' to attach" | |
sudo ip link set dev at0 up | |
sudo ip addr add 192.168.1.1/24 dev at0 | |
sudo killall dnsmasq | |
sleep 5 | |
sudo rm -f /home/gals/wifi/scripts/dnsmasq.log | |
sudo dnsmasq -z -i at0 --listen-address 192.168.1.1 --dhcp-range='at0,192.168.1.100,192.168.1.120,12h' --dhcp-option='1,255.255.255.0' --dhcp-option='3,192.168.1.1' --dhcp-option='6,192.168.1.1' --log-facility=/home/gals/wifi/scripts/dnsmasq.log --log-dhcp --log-queries -h | |
sudo iptables -D FORWARD -i at0 -d ${HOME_NETWORK_1} -j DROP | |
sudo iptables -A FORWARD -i at0 -d ${HOME_NETWORK_1} -j DROP | |
sudo iptables -D FORWARD -i at0 -d ${HOME_NETWORK_2} -j DROP | |
sudo iptables -A FORWARD -i at0 -d ${HOME_NETWORK_2} -j DROP | |
sudo iptables -D INPUT -i at0 -p udp --dport 53 -j ACCEPT | |
sudo iptables -A INPUT -i at0 -p udp --dport 53 -j ACCEPT | |
sudo iptables -D INPUT -i at0 -p udp --dport 67 -j ACCEPT | |
sudo iptables -A INPUT -i at0 -p udp --dport 67 -j ACCEPT | |
sudo iptables -D INPUT -i at0 -j DROP | |
sudo iptables -A INPUT -i at0 -j DROP | |
sudo iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE | |
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | |
sudo killall tcpdump | |
sleep 5 | |
tmux new-session -d -s tcpdump sudo tcpdump -ni at0 -s0 -w /big/dump/$(date +%Y-%m-%d_%H-%M).pcap | |
sudo tc qdisc del dev ${WIFI_INT} root &> /dev/null | |
sudo tc qdisc add dev ${WIFI_INT} root handle 1: htb default 1 | |
sudo tc class add dev ${WIFI_INT} parent 1: classid 1:1 htb rate 1mbit | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment