X-Git-Url: http://lab.mitty.jp/git/?a=blobdiff_plain;f=iptables%2Fsetnapt.sh;h=801cba04f9018ce4ce4141029f156ea10173672b;hb=b9ae53a95b312d5a987461ac4966bcbb88e3c5b0;hp=d34ba375e9f3856f6f56cf993defd6350738a7e6;hpb=4a36a1b26f4cdc2dc3d06d7b3c4ac895b0083b2f;p=lab.git diff --git a/iptables/setnapt.sh b/iptables/setnapt.sh old mode 100644 new mode 100755 index d34ba37..801cba0 --- a/iptables/setnapt.sh +++ b/iptables/setnapt.sh @@ -8,10 +8,10 @@ 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. +# 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) @@ -30,7 +30,7 @@ fi sleep 60 if [ -z "${GATEWAYS}" ]; then - GATEWAYS=`/sbin/ip route show table main | grep -w default | cut -d ' ' -f 5` + GATEWAYS=`/sbin/ip route show table main | grep -w default | tr -s ' ' | cut -d ' ' -f 5` fi for GW in ${GATEWAYS}; do @@ -39,10 +39,10 @@ for GW in ${GATEWAYS}; do continue fi - IPADDR=`/sbin/ip addr show dev ${GW} | grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2 | cut -d / -f 1` + IPADDR=`/sbin/ip addr show dev ${GW} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1` if [ -z "${IPADDR}" ]; then # device doesn't seem to have an IP address - break + continue fi ## set masquerade rule to all devices