您的位置:首页 > 运维架构 > Linux

双线机房双IP linux设置路由

2014-07-18 16:06 232 查看
本文转账自http://www.itxinxi.net/blog/read.php/401.htm
vi /etc/iproute2/rt_tables

#
# reserved values
#
255 local
254 main
253 default
0 unspec
252 ct
251 cnc


#
# local
#
#1 inr.ruhep

ip route flush table ct
ip route add default via 电信网关IP dev 网卡号(比如:eth0) src 电信IP table ct
ip rule add from 电信IP table ct

ip route flush table cnc
ip route add default via 网通网关IP dev 网卡号(比如:eth1) src 网通IP table cnc
ip rule add from 网通IP table cnc

以上脚本 做成 .sh脚本后 增加到服务器启动项

查看路由
ip route

115.238.229.160/27 dev eth0 proto kernel scope link src 115.238.229.175
101.64.237.0/26 dev eth1 proto kernel scope link src 101.64.237.43
169.254.0.0/16 dev eth1 scope link
default via 115.238.229.161 dev eth0

查看网关:route

添加默认路由:

route add –net 0.0.0.0 netmask 0.0.0.0 gw 192.168.0.1

[root@localhost ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
101.226.249.192 * 255.255.255.240 U 0 0 0 eth1
210.51.47.128 * 255.255.255.128 U 0 0 0 eth0
default 101.226.249.193 0.0.0.0 UG 0 0 0 eth1
default 210.51.47.129 0.0.0.0 UG 0 0 0 eth0

查看机器所有路由表详细情况
ip route show table all

查看表252的路由情况
ip route list table 252

查看简洁路由表信息
ip route show all
ip route list

刷新路由表
ip route flush table 252
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux 路由 双线