projects
/
lab.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* FIX: warning 'Use of uninitialized value $ARGV[0]' on non debug mode
[lab.git]
/
iptables
/
setlan2wan.sh
diff --git
a/iptables/setlan2wan.sh
b/iptables/setlan2wan.sh
index
ac9c617
..
5594949
100644
(file)
--- 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.
# PHASE as per MODE, but with finer granularity, distinguishing the pre-
# up, post-up, pre-down and post-down phases.
-LANIF="${1:?"usage: $0 <LAN_device> "}"
-
-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 <LAN_device> <IPADDR> "}"
+LANIP="${2:?"usage: $0 <LAN_device> <IPADDR> "}"
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
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
echo "remove rule for access to WAN device on router node from LAN clients"
exit
fi
@@
-31,7
+29,7
@@
fi
(
sleep 60
(
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"
) &
echo "set rule for access to WAN device on router node from LAN clients"
) &