X-Git-Url: http://lab.mitty.jp/git/?a=blobdiff_plain;f=iptables%2Fsetmasq.sh;fp=iptables%2Fsetmasq.sh;h=0f3f80f1bc621ffa3a3fc49c5588f346c3a2ef94;hb=e829fd8dfc421a415a74d8719469a1a7c024e438;hp=0000000000000000000000000000000000000000;hpb=c8daa6983248628690543c953d99bad4dd6cb64d;p=lab.git diff --git a/iptables/setmasq.sh b/iptables/setmasq.sh new file mode 100755 index 0000000..0f3f80f --- /dev/null +++ b/iptables/setmasq.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# set IP MASQUERADE with post-up command in INTERFACES(5) + + +set -x + +## INTERFACES(5) +# IFACE physical name of the interface being processed +# METHOD method of the interface (e.g., static) +# MODE start if run from ifup, stop if run from ifdown +# PHASE as per MODE, but with finer granularity, distinguishing the pre- +# up, post-up, pre-down and post-down phases. + +# optional argument to set default gateway devices connected to WAN manually +# (try each of them in order) + +if [ "${PHASE}" = "post-down" ]; then + # remove MASQUERADE rule and exit + /sbin/iptables -t nat -D POSTROUTING -o ${IFACE} -j MASQUERADE + exit +fi + + +# set MASQUERADE rule +/sbin/iptables -t nat -A POSTROUTING -o ${IFACE} -j MASQUERADE