3 # enable access to WAN device on router node from LAN clients
9 # IFACE physical name of the interface being processed
10 # METHOD method of the interface (e.g., static)
11 # MODE start if run from ifup, stop if run from ifdown
12 # PHASE as per MODE, but with finer granularity, distinguishing the pre-
13 # up, post-up, pre-down and post-down phases.
15 LANIF="${1:?"usage: $0 <LAN_device> <IPADDR> "}"
16 LANIP="${2:?"usage: $0 <LAN_device> <IPADDR> "}"
18 WANIP=`/sbin/ip addr show dev ${IFACE} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1`
20 if [ "${PHASE}" = "pre-down" ]; then
21 # delete rule and exit
22 /sbin/iptables -t nat -D PREROUTING -i ${LANIF} -d ${WANIP} -j DNAT --to-destination ${LANIP}
23 echo "remove rule for access to WAN device on router node from LAN clients"
32 /sbin/iptables -t nat -A PREROUTING -i ${LANIF} -d ${WANIP} -j DNAT --to-destination ${LANIP}
33 echo "set rule for access to WAN device on router node from LAN clients"