wd and cc

— Happy every day

Linux下双网接入高级路由配置脚本zz

Posted at — Jan 12, 2006
http://lwfs.net/2005/11/28/10/
    #!/bin/bash

    IP0=
    IP1=
    GW0=
    GW1=
    NET0=
    NET1=
    DEV0=eth0
    DEV1=eth1

    # comment the next two line after first run this script.
    echo 200 cernet >>/etc/iproute2/rt_tables
    echo 210 chinanet >>/etc/iproute2/rt_tables

    ip route add ${NET0} dev ${DEV0} src ${IP0} table cernet
    ip route add default via ${GW0} table cernet
    ip route add ${NET1} dev ${DEV1} src ${IP1} table chinanet
    ip route add default via ${GW1} table chinanet
    ip route add ${NET0} dev ${DEV0} src ${IP0}
    ip route add ${NET1} dev ${DEV1} src ${IP1}

    # delete old rule
    ip rule del from ${IP0}
    ip rule del from ${IP1}
    # setup new rule
    ip rule add from ${IP0} table cernet
    ip rule add from ${IP1} table chinanet 

comments powered by Disqus