Skip to content

Instantly share code, notes, and snippets.

@abenson
Created February 24, 2022 23:44
Show Gist options
  • Save abenson/422eafeb9b04a7b88a4b215c9286114c to your computer and use it in GitHub Desktop.
Save abenson/422eafeb9b04a7b88a4b215c9286114c to your computer and use it in GitHub Desktop.
Share WLAN to Ethernet
#!/bin/sh
SYSCTL="sysctl -w net.ipv4.ip_forward"
case "$1" in
"-e")
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -I POSTROUTING -o wlan0 -j MASQUERADE
iptables -I FORWARD -i eth0 -o wlan0 -j ACCEPT
ip addr del 10.10.10.1 dev eth0
;;
"-d")
sysctl -w net.ipv4.ip_forward=0
iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE
iptables -D FORWARD -i eth0 -j ACCEPT
ip addr add 10.10.10.1 dev eth0
;;
*)
echo "usage: share-wlan.sh [-e|-d]"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment