Changeset 14 in lab
- Timestamp:
- Jul 6, 2009 2:49:54 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/iproute/setroute-rhel.sh
r10 r14 3 3 set -x 4 4 5 IF ="${1:?"usage: $0 <ether_device> [gateway] "}"5 IFACE="${1:?"usage: $0 <ether_device> [gateway] "}" 6 6 GATEWAY=$2 7 7 8 TID=`/sbin/ip addr show dev ${IF } | grep -w ${IF}:| cut -d : -f 1`8 TID=`/sbin/ip addr show dev ${IFACE} | grep -w ${IFACE}: | tr -s ' ' | cut -d : -f 1` 9 9 10 10 if [ "${GATEWAY}" = "down" ]; then … … 15 15 /sbin/ip rule del table ${TID} priority ${TID} 16 16 /sbin/ip route flush cache 17 echo "remove routing table and policy for ${IF }"17 echo "remove routing table and policy for ${IFACE}" 18 18 exit 19 19 fi … … 21 21 22 22 # get IP address, network mask, default gateway info 23 IPADDR=`/sbin/ip addr show dev ${IF } | grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2| cut -d / -f 1`24 NETWORK=`/sbin/ip route show dev ${IF } | grep -w ${IPADDR}| cut -d ' ' -f 1`23 IPADDR=`/sbin/ip addr show dev ${IFACE} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1` 24 NETWORK=`/sbin/ip route show dev ${IFACE} | grep -w ${IPADDR} | tr -s ' ' | cut -d ' ' -f 1` 25 25 26 26 if [ -z "${GATEWAY}" ]; then 27 GATEWAY=`/sbin/ip route show dev ${IF } | grep -w default| cut -d ' ' -f 3`27 GATEWAY=`/sbin/ip route show dev ${IFACE} | grep -w default | tr -s ' ' | cut -d ' ' -f 3` 28 28 fi 29 29 if [ -z "${GATEWAY}" ]; then 30 GATEWAY=`/sbin/ip route | grep -w default | cut -d ' ' -f 3`30 GATEWAY=`/sbin/ip route | grep -w default | tr -s ' ' | cut -d ' ' -f 3` 31 31 # this may add wrong default route especially on RHEL 32 32 fi … … 34 34 35 35 # set routing table 36 /sbin/ip route add ${NETWORK} dev ${IF } table ${TID}37 /sbin/ip route add default via ${GATEWAY} dev ${IF } table ${TID}36 /sbin/ip route add ${NETWORK} dev ${IFACE} table ${TID} 37 /sbin/ip route add default via ${GATEWAY} dev ${IFACE} table ${TID} 38 38 39 39 # set routing policy … … 41 41 42 42 /sbin/ip route flush cache 43 echo "add routing table and policy for ${IF } on table ${TID}"43 echo "add routing table and policy for ${IFACE} on table ${TID}" -
trunk/iproute/setroute.sh
r10 r14 16 16 GATEWAY=$1 17 17 18 TID=`/sbin/ip addr show dev ${IFACE} | grep -w ${IFACE}: | cut -d : -f 1`18 TID=`/sbin/ip addr show dev ${IFACE} | grep -w ${IFACE}: | tr -s ' ' | cut -d : -f 1` 19 19 20 20 if [ "${PHASE}" = "post-down" ]; then … … 31 31 32 32 # get IP address, network mask, default gateway info 33 IPADDR=`/sbin/ip addr show dev ${IFACE} | grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2| cut -d / -f 1`33 IPADDR=`/sbin/ip addr show dev ${IFACE} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1` 34 34 if [ -z "${IPADDR}" ]; then 35 35 # fail to bind IP address to device … … 37 37 exit 38 38 fi 39 NETWORK=`/sbin/ip route show dev ${IFACE} | grep -w ${IPADDR} | cut -d ' ' -f 1`39 NETWORK=`/sbin/ip route show dev ${IFACE} | grep -w ${IPADDR} | tr -s ' ' | cut -d ' ' -f 1` 40 40 41 41 if [ -z "${GATEWAY}" ]; then 42 GATEWAY=`/sbin/ip route show dev ${IFACE} | grep -w default | cut -d ' ' -f 3`42 GATEWAY=`/sbin/ip route show dev ${IFACE} | grep -w default | tr -s ' ' | cut -d ' ' -f 3` 43 43 fi 44 44 if [ -z "${GATEWAY}" ]; then 45 GATEWAY=`/sbin/ip route | grep -w default | cut -d ' ' -f 3`45 GATEWAY=`/sbin/ip route | grep -w default | tr -s ' ' | cut -d ' ' -f 3` 46 46 # this may add wrong default route especially on RHEL 47 47 fi -
trunk/iptables/setnapt.sh
r10 r14 31 31 32 32 if [ -z "${GATEWAYS}" ]; then 33 GATEWAYS=`/sbin/ip route show table main | grep -w default | cut -d ' ' -f 5`33 GATEWAYS=`/sbin/ip route show table main | grep -w default | tr -s ' ' | cut -d ' ' -f 5` 34 34 fi 35 35 … … 40 40 fi 41 41 42 IPADDR=`/sbin/ip addr show dev ${GW} | grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2| cut -d / -f 1`42 IPADDR=`/sbin/ip addr show dev ${GW} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1` 43 43 if [ -z "${IPADDR}" ]; then 44 44 # device doesn't seem to have an IP address
Note: See TracChangeset
for help on using the changeset viewer.