|
@@ -1,6 +1,32 @@
|
|
#!/bin/sh
|
|
#!/bin/sh
|
|
#
|
|
#
|
|
|
|
|
|
|
|
+flush_all() {
|
|
|
|
+# Accept all traffic first to avoid ssh lockdown via iptables firewall rules #
|
|
|
|
+iptables -P INPUT ACCEPT
|
|
|
|
+iptables -P FORWARD ACCEPT
|
|
|
|
+iptables -P OUTPUT ACCEPT
|
|
|
|
+
|
|
|
|
+# Flush All Iptables Chains/Firewall rules #
|
|
|
|
+iptables -F
|
|
|
|
+
|
|
|
|
+# Delete all Iptables Chains #
|
|
|
|
+iptables -X
|
|
|
|
+
|
|
|
|
+# Flush all counters too #
|
|
|
|
+iptables -Z
|
|
|
|
+# Flush and delete all nat and mangle #
|
|
|
|
+iptables -t nat -F
|
|
|
|
+iptables -t nat -X
|
|
|
|
+iptables -t mangle -F
|
|
|
|
+iptables -t mangle -X
|
|
|
|
+#-------------------------
|
|
|
|
+iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
|
|
|
+iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
|
|
|
|
+iptables -t nat -A POSTROUTING -o tun5 -j MASQUERADE
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
del_portfwd () {
|
|
del_portfwd () {
|
|
DESTPORT=$1
|
|
DESTPORT=$1
|
|
DESTIP=$2
|
|
DESTIP=$2
|
|
@@ -20,14 +46,15 @@ SRCPORT=$3
|
|
SRCIP=$4
|
|
SRCIP=$4
|
|
SRCIFACE=$5
|
|
SRCIFACE=$5
|
|
|
|
|
|
-del_portfwd $1 $2 $3 $4 $5
|
|
|
|
|
|
+#del_portfwd $1 $2 $3 $4 $5
|
|
|
|
|
|
iptables -t nat -A PREROUTING -p tcp -i $SRCIFACE --dport $SRCPORT -j DNAT --to-destination $DESTIP:$DESTPORT
|
|
iptables -t nat -A PREROUTING -p tcp -i $SRCIFACE --dport $SRCPORT -j DNAT --to-destination $DESTIP:$DESTPORT
|
|
iptables -A FORWARD -p tcp -d $SRCIP --dport $SRCPORT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
|
|
iptables -A FORWARD -p tcp -d $SRCIP --dport $SRCPORT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-#set_portfwd 80 192.168.0.1 80 192.168.7.2 usb0
|
|
|
|
|
|
+flush_all
|
|
|
|
+
|
|
set_portfwd 80 192.168.100.1 80 `ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'` eth0
|
|
set_portfwd 80 192.168.100.1 80 `ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'` eth0
|
|
set_portfwd 80 192.168.100.1 80 `ifconfig tun5 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'` tun5
|
|
set_portfwd 80 192.168.100.1 80 `ifconfig tun5 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'` tun5
|
|
set_portfwd 102 192.168.100.1 102 `ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'` eth0
|
|
set_portfwd 102 192.168.100.1 102 `ifconfig eth0 2>/dev/null|awk '/inet addr:/ {print $2}'|sed 's/addr://'` eth0
|