33 lines
649 B
Bash
33 lines
649 B
Bash
|
#!/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
|