Last active
March 11, 2019 20:27
-
-
Save Lewiscowles1986/f303d66676340d9aa3cf6ef1b672c0c9 to your computer and use it in GitHub Desktop.
Allows passthrough for bridges, wireless access-point's and range extenders
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 | |
if [ "$EUID" -ne 0 ] | |
then echo "Must be root" | |
exit | |
fi | |
ADAPTER="eth0" | |
# Allow overriding from eth0 by passing in a single argument | |
if [ $# -eq 1 ]; then | |
ADAPTER="$1" | |
fi | |
#Uncomment net.ipv4.ip_forward | |
sed -i -- 's/#net.ipv4.ip_forward/net.ipv4.ip_forward/g' /etc/sysctl.conf | |
#Change value of net.ipv4.ip_forward if not already 1 | |
sed -i -- 's/net.ipv4.ip_forward=0/net.ipv4.ip_forward=1/g' /etc/sysctl.conf | |
#Activate on current system | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
iptables -t nat -A POSTROUTING -o $ADAPTER -j MASQUERADE | |
iptables -A FORWARD -i $ADAPTER -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT | |
iptables -A FORWARD -i wlan0 -o $ADAPTER -j ACCEPT |
@vicatcu yeah raspbian stretch has some awful decisions including the renaming of adapters. Try working with https://gist.github.com/Lewiscowles1986/390d4d423a08c4663c0ada0adfe04cdb as well to allow you to set /etc/network/interfaces
as you've indicated you have here.
Big Picture
- the script accepts an interface, it's documented above, use it for whatever your eth0 is called.
- this is only designed for raspbian without edits (although it should work on most vanilla debian-based distro's)
- the script linked helps get interfaces started if you've edited
/etc/network/interfaces
in a debian-based distro using the raspbian setup (to skip any networking if a single interface is defined in/etc/network/interfaces
...)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot, I've tried several ways, but finally I just use your code, and it works!