Changeset 3a5184c in lab.git for iptables


Ignore:
Timestamp:
Jul 7, 2009 11:48:58 PM (15 years ago)
Author:
mitty <mitty@…>
Branches:
master, trunk
Children:
b9ae53a
Parents:
7c270d4
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

git-svn-id: https://lab.mitty.jp/svn/lab/trunk@19 7d2118f6-f56c-43e7-95a2-4bb3031d96e7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • iptables/setlan2wan.sh

    r7c270d4 r3a5184c  
    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.