案例:
内网IP:10.2.0.3
外网IP:60.2.18.10
内网网关:10.2.0.1
外网网关:60.2.18.1
备注:默认网关写在/etc/sysconfig/network里,是外网网关,静态路由写在/etc/sysconfig/static-routes 里,这样重启网络也不会丢失了~

#!/bin/bash
sed -i \'/^/sbin/route/d\' /etc/rc.local
echo "DEVICE=eth0
ONBOOT=yes "> /etc/sysconfig/network-scripts/ifcfg-eth0
awk -F \'"\' \'/IPADDR/{print $1$2}\' /etc/sysconfig/network-scripts/ifcfg-bond0 >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "DEVICE=eth1
ONBOOT=yes" > /etc/sysconfig/network-scripts/ifcfg-eth1
sed -n \'/IPADDR/p\' /etc/sysconfig/network-scripts/ifcfg-bond0|sed -r \'s/(.*).137.(.*)"/2/g\'|awk \'{system("echo "$1"+58")}\'|awk -F. \'{print "IPADDR=60.XX.XX."$4+60}\' >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo "NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-eth1
sed -i "/^GATEWAY/d" /etc/sysconfig/network
echo "GATEWAY=60.2.18.1" >> /etc/sysconfig/network
echo "any net 10.0.0.0/8 gw 10.16.0.1
any net 172.0.0.0/8 gw 10.16.0.1" >/etc/sysconfig/static-routes
#sed -i \'6,9d\' /etc/modprobe.conf
rm -f /etc/modprobe.d/bonding.conf
sleep 2
mv /etc/sysconfig/network-scripts/ifcfg-bond0 /etc/sysconfig/network-scripts/ifcfg-bond0.bak

哟?不错哎 订阅小米的RSS Feeds 回去慢慢看^_^