1
0
mirror of https://github.com/tomeshnet/prototype-cjdns-pi synced 2025-10-05 23:52:49 +02:00

[Contrib] Captive Portal like lock for internet bound connection on an offline node (#229)

This commit is contained in:
darkdrgn2k
2018-12-25 21:11:28 -05:00
committed by GitHub
parent 6946f13e15
commit a8ec3c9a29

View File

@@ -0,0 +1,17 @@
#!/bin/sh
# Backup file
if ! [ -f "/etc/hostapd/nat.sh.bak" ]; then
sudo cp /etc/hostapd/nat.sh /etc/hostapd/nat.sh.bak
fi
# Redirect all IPv4 80 traffic to the pi
echo iptables -t nat -I PREROUTING -i wlan-ap -p tcp --dport 80 -j DNAT --to-destination 10.0.0.1:80 | sudo tee --append /etc/hostapd/nat.sh > /dev/null
# Prevent masquerading out IPv4
# This is to prevent IPTUNNEL and routing to the internet (Exit node)
sudo sed -i "/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE/d" /etc/hostapd/nat.sh
# Set nginx to redirect any 404 errors to /
sed -i '$i error_page 404 =200 /index.html;' /etc/nginx/sites-enabled/main.conf
sudo systemctl restart hostapd