X-Git-Url: http://lab.mitty.jp/git/?a=blobdiff_plain;f=iptables%2Fsetlan2wan.sh;h=55949494d700a862d0520819ea9b5322b10a15fa;hb=3a5184c7b3a10b965dc4c8aa112251f8b756da8a;hp=ca9e94a139938b3fe4b4ab2a4f5872f8b3730e45;hpb=e829fd8dfc421a415a74d8719469a1a7c024e438;p=lab.git diff --git a/iptables/setlan2wan.sh b/iptables/setlan2wan.sh index ca9e94a..5594949 100644 --- a/iptables/setlan2wan.sh +++ b/iptables/setlan2wan.sh @@ -12,21 +12,24 @@ set -x # PHASE as per MODE, but with finer granularity, distinguishing the pre- # up, post-up, pre-down and post-down phases. -LANIF="${1:?"usage: $0 "}" - -LANIP=`/sbin/ip addr show dev ${LANIF} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1` -LANMASK=`/sbin/ip route show dev ${LANIF} | grep -w ${LANIP} | tr -s ' ' | cut -d ' ' -f 1` +LANIF="${1:?"usage: $0 "}" +LANIP="${2:?"usage: $0 "}" WANIP=`/sbin/ip addr show dev ${IFACE} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1` if [ "${PHASE}" = "pre-down" ]; then # delete rule and exit - /sbin/iptables -t nat -D PREROUTING -i ${LANIF} -s ${LANMASK} -d ${WANIP} -j DNAT --to-destination ${LANIP} + /sbin/iptables -t nat -D PREROUTING -i ${LANIF} -d ${WANIP} -j DNAT --to-destination ${LANIP} echo "remove rule for access to WAN device on router node from LAN clients" exit fi # set rule -/sbin/iptables -t nat -A PREROUTING -i ${LANIF} -s ${LANMASK} -d ${WANIP} -j DNAT --to-destination ${LANIP} +( +sleep 60 + +/sbin/iptables -t nat -A PREROUTING -i ${LANIF} -d ${WANIP} -j DNAT --to-destination ${LANIP} echo "set rule for access to WAN device on router node from LAN clients" + +) &