diff options
| author | grothedev <grothedev@gmail.com> | 2023-06-28 11:08:16 -0500 |
|---|---|---|
| committer | grothedev <grothedev@gmail.com> | 2023-06-28 11:08:16 -0500 |
| commit | 7471e3732c128eec9c993481fdae7b925052d429 (patch) | |
| tree | 56742dcae86f9df91d94c3cd91204dfdf22e9865 | |
| parent | 1818b37dc142b8f8d12cf2f1069378638ed1550b (diff) | |
added wifi hotspot stuff
| -rwxr-xr-x | initWifiHotspot.sh | 30 | ||||
| -rwxr-xr-x | whatip | 2 |
2 files changed, 32 insertions, 0 deletions
diff --git a/initWifiHotspot.sh b/initWifiHotspot.sh new file mode 100755 index 0000000..f307427 --- /dev/null +++ b/initWifiHotspot.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Usage: ./{executable} {wifi_card_interface} {interface_with_internet} +########### Initial wifi interface configuration ############# +sudo ip link set $1 down +sudo ip addr flush dev $1 +sudo ip link set $1 up +sudo ip addr add 10.0.0.1/24 dev $1 +# If you still use ifconfig for some reason, replace the above lines with the following +# ifconfig $1 up 10.0.0.1 netmask 255.255.255.0 +sleep 2 +########### +########### Start dnsmasq ########## +if [ -z "$(ps -e | grep dnsmasq)" ] +then + sudo dnsmasq +fi +########### +########### Enable NAT ############ +sudo iptables -t nat -A POSTROUTING -o $2 -j MASQUERADE +sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT +sudo iptables -A FORWARD -i $1 -o $2 -j ACCEPT +#Thanks to lorenzo +#Uncomment the line below if facing problems while sharing PPPoE, see lorenzo's comment for more details +#iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu +#sudo sysctl -w net.ipv4.ip_forward=1 +########### +########## Start hostapd ########### +#hostapd /etc/hostapd/hostapd.conf +sudo systemctl restart hostapd +sudo killall dnsmasq @@ -0,0 +1,2 @@ +#!/bin/bash +ip -4 -f inet address show dev wlp4s0 | grep 192 | awk '{print $2}' | cut -d'/' -f 1 |
