双线机房双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
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下修改IP、DNS、路由命令行设置
- Linux下修改IP、DNS、路由设置
- linux下修改IP、DNS、路由设置
- 如何在Linux路由上设置IP和MAC绑定
- 如何在Linux路由上设置IP和MAC绑定?
- IFCONFIG-linux下修改IP、DNS、路由设置
- Linux下修改IP、DNS、路由命令行设置
- linux下修改IP、DNS、路由命令行设置
- 在linux路由上设置IP和MAC绑定
- Linux下修改IP、DNS、路由命令行设置
- linux/windows系统设置ip、网关、加路由
- linux ip 网关 掩码 mac 路由 dns设置方法
- linux下修改IP、DNS、路由设置
- linux设置IP路由等网络命令汇总
- linux下修改IP、DNS、路由命令行设置
- linux下的路由设置(把linux作为路由器来使用)
- LINUX环境下Iprouter2 + iptables + tc 双线策略路由(转)
- 如何理解ip路由和操作linux的路由表
- Ubuntu Linux系统下设置静态IP的方法
- Linux下的IP设置