X-Git-Url: http://lab.mitty.jp/git/?a=blobdiff_plain;f=iproute%2Fsetroute-rhel.sh;fp=iproute%2Fsetroute-rhel.sh;h=0000000000000000000000000000000000000000;hb=8333ea00a9fe608c90c20af12ea0c51548f66f4e;hp=9314dd96a17f811550e324da2ca934ce95f60e4a;hpb=920ad9e17feea13643c407944f9452b03bd45b6e;p=lab.git diff --git a/iproute/setroute-rhel.sh b/iproute/setroute-rhel.sh deleted file mode 100755 index 9314dd9..0000000 --- a/iproute/setroute-rhel.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -set -x - -IFACE="${1:?"usage: $0 [gateway] "}" -GATEWAY=$2 - -TID=`/sbin/ip addr show dev ${IFACE} | grep -w ${IFACE}: | tr -s ' ' | cut -d : -f 1` - -if [ "${GATEWAY}" = "down" ]; then - # delete routing table and policy and exit - ## routing table is automatically flushed, so 'route flush' can be removed - /sbin/ip route flush table ${TID} - ## device has no longer any IP addr, so do not use IPADDR - /sbin/ip rule del table ${TID} priority ${TID} - /sbin/ip route flush cache - echo "remove routing table and policy for ${IFACE}" - exit -fi - - -# get IP address, network mask, default gateway info -IPADDR=`/sbin/ip addr show dev ${IFACE} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1` -NETWORK=`/sbin/ip route show dev ${IFACE} | grep -w ${IPADDR} | tr -s ' ' | cut -d ' ' -f 1` - -if [ -z "${GATEWAY}" ]; then - GATEWAY=`/sbin/ip route show dev ${IFACE} | grep -w default | tr -s ' ' | cut -d ' ' -f 3` -fi -if [ -z "${GATEWAY}" ]; then - GATEWAY=`/sbin/ip route | grep -w default | tr -s ' ' | cut -d ' ' -f 3` - # this may add wrong default route especially on RHEL -fi - - -# set routing table -/sbin/ip route add ${NETWORK} dev ${IFACE} table ${TID} -/sbin/ip route add default via ${GATEWAY} dev ${IFACE} table ${TID} - -# set routing policy -/sbin/ip rule add from ${IPADDR} table ${TID} priority ${TID} - -/sbin/ip route flush cache -echo "add routing table and policy for ${IFACE} on table ${TID}"