Changeset 19 in lab


Ignore:
Timestamp:
Jul 7, 2009 11:48:58 PM (15 years ago)
Author:
mitty
Message:
  • 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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/iptables/setlan2wan.sh

    r18 r19  
    1313#        up, post-up, pre-down and post-down phases. 
    1414 
    15 LANIF="${1:?"usage: $0 <LAN_device> "}" 
    16  
    17 LANIP=`/sbin/ip addr show dev ${LANIF} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1` 
    18 LANMASK=`/sbin/ip route show dev ${LANIF} | grep -w ${LANIP} | tr -s ' ' | cut -d ' ' -f 1` 
     15LANIF="${1:?"usage: $0 <LAN_device> <IPADDR> "}" 
     16LANIP="${2:?"usage: $0 <LAN_device> <IPADDR> "}" 
    1917 
    2018WANIP=`/sbin/ip addr show dev ${IFACE} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1` 
     
    2220if [ "${PHASE}" = "pre-down" ]; then 
    2321    # delete rule and exit 
    24     /sbin/iptables -t nat -D PREROUTING -i ${LANIF} -s ${LANMASK} -d ${WANIP} -j DNAT --to-destination ${LANIP} 
     22    /sbin/iptables -t nat -D PREROUTING -i ${LANIF} -d ${WANIP} -j DNAT --to-destination ${LANIP} 
    2523    echo "remove rule for access to WAN device on router node from LAN clients" 
    2624    exit 
     
    3230sleep 60 
    3331 
    34 /sbin/iptables -t nat -A PREROUTING -i ${LANIF} -s ${LANMASK} -d ${WANIP} -j DNAT --to-destination ${LANIP} 
     32/sbin/iptables -t nat -A PREROUTING -i ${LANIF} -d ${WANIP} -j DNAT --to-destination ${LANIP} 
    3533echo "set rule for access to WAN device on router node from LAN clients" 
    3634 
Note: See TracChangeset for help on using the changeset viewer.