Add share_internet script

This commit is contained in:
Markus Koch 2021-03-29 10:55:32 +02:00
parent c09da52343
commit 438604088c

32
network/share_internet.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
if [ "`id -u`" -ne 0 ]; then
echo "Need to be root."
exit
fi
DINET=`ip link | sed -n 's/.*\(wlp[^:]\+\).*/\1/p' | head -n1`
DETH=`ip link | sed -n 's/.*\(enp[^:]\+\).*/\1/p' | head -n1`
echo -n "Internet on [$DINET]: "
read TEMP
if [ "$TEMP" != "" ]; then
DINET="$TEMP"
fi
echo -n "Forward to [$DETH]: "
read TEMP
if [ "$TEMP" != "" ]; then
DETH="$TEMP"
fi
echo ""
echo "Forwarding internet from $DINET to $DETH."
exit
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o $DINET -j MASQUERADE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i $DETH -o $DINET -j ACCEPT