All pastes #534884 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-06-03 22:27 UTC
rendered paste body
config_eth1=(
"192.168.58.130/24"
"192.168.58.5/24"
"192.168.58.6/24"
"192.168.58.7/24""192.168.58.8/24"
"192.168.58.9/24"
 )
routes_eth1=(
"default via 192.168.58.2 table 254"
 )
postup() {
    local x="rules_${IFVAR}[@]"
    local -a rules=( "${!x}" )
    if [[ -n ${rules} ]] ; then
        einfo "Adding IP policy routing rules"
        eindent
        if ! ip rule list | grep -q "^" ; then
            eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)"
            eerror "in your kernel to use ip rules"
        else
            for x in "${rules[@]}" ; do
                ebegin "${x}"
                ip rule add ${x} dev "${IFACE}"
                eend $? 
            done
        fi  
        eoutdent
        ip route flush cache dev "${IFACE}"
    fi  
    
}   

postdown() {
    if interface_exists "${IFACE}" ; then
        local rule
        ip rule list | grep " iif ${IFACE}[ ]*" | {
            while read rule ; do
                rule="${rule#*:}"
                ip rule del ${rule}
            done
        }   
        ip route flush cache dev "${IFACE}"
    fi  
    return 0
}