linux双线路由配置方法介绍。
第一步:
ifconfig 查看网卡信息,记下eth0,eth1(不一定是像eth0这样编号)ip
eth0:211.152.33.34
eth1:203.166.33.34
第二步:
编辑/etc/iproute2/rt_tables(路由表)
vi /etc/iproute2/rt_tables
11 tel
12 uni
实例:
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
10 lan
11 tel
12 uni
第三步:
去/etc/sysconfig/network-scripts/写规则
共需创建四个文件:
第一个:vi /etc/sysconfig/network-scripts/route-eth0
内容(假使是电信网卡):
default via 211.152.33.1 dev eth0 src 211.152.33.34 table tel
完事之后保存退出 :wq!
第二个:vi /etc/sysconfig/network-scripts/route-eth1
内容(假使是联通网卡):
default via 203.166.33.1 dev eth1 src 203.166.33.34table uni
default via 203.166.33.1 dev eth1 table main (默认路由)
完事之后保存退出 :wq!
第三个:vi /etc/sysconfig/network-scripts/rule-eth0
内容(假使是电信网卡):from 211.152.33.34 table tel
完事之后保存退出 :wq!
第四个:vi /etc/sysconfig/network-scripts/rule-eth1
内容(假使是联通网卡)from 203.166.33.34 table uni
完事之后保存退出 :wq!
第四部:给四个文件加上root权限:
chmod +x /etc/sysconfig/network-scripts/route-eth0
chmod +x /etc/sysconfig/network-scripts/route-eth1
chmod +x /etc/sysconfig/network-scripts/rule-eth0
chmod +x /etc/sysconfig/network-scripts/rule-eth1
最后重启,完成路由设置。
您服务器的网关地址:
电信:211.152.33.1
联通:203.166.33.1