From 3a5184c7b3a10b965dc4c8aa112251f8b756da8a Mon Sep 17 00:00:00 2001 From: mitty Date: Tue, 7 Jul 2009 14:48:58 +0000 Subject: [PATCH] * FIX: now the script needs 2nd argument to fix IP address of LAN device * LAN device can be down before the this script is invoked git-svn-id: https://lab.mitty.jp/svn/lab/trunk@19 7d2118f6-f56c-43e7-95a2-4bb3031d96e7 --- iptables/setlan2wan.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/iptables/setlan2wan.sh b/iptables/setlan2wan.sh index ac9c617..5594949 100644 --- a/iptables/setlan2wan.sh +++ b/iptables/setlan2wan.sh @@ -12,16 +12,14 @@ 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 @@ -31,7 +29,7 @@ fi ( sleep 60 -/sbin/iptables -t nat -A PREROUTING -i ${LANIF} -s ${LANMASK} -d ${WANIP} -j DNAT --to-destination ${LANIP} +/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" ) & -- 1.7.9.5