1、服务器IP地址配置
eth0: 120.52.139.30/29 网关 120.52.139.25 联通地址
eth1: 123.58.236.11/28 网关 123.58.236.1 电信地址
eth2 : 112.35.19.38/29 网关 112.35.19.33 移动地址
2、配置路由表标签
[[email protected] ~]# cat /etc/iproute2/rt_tables
#
# reserved values
#
255 local
254 main
253 default
252 cnc
251 ct
250 yd
0 unspec
#
# local
#
#1 inr.ruhep
3、执行下面的命令
ip route add default via 120.52.139.25 dev eth0 src 120.52.139.30 table cnc
ip rule add from 120.52.139.30 table cnc
ip route add default via 123.58.236.1 dev eth1 src 123.58.236.11 table ct
ip rule add from 123.58.236.11 table ct
ip route add default via 112.35.19.33 dev eth2 src 112.35.19.38 table yd
ip rule add from 112.35.19.38 table yd
4、把上面的命令放到开机自启动脚本
[[email protected] ~]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don‘t
# want to do the full Sys V style init stuff.
ip route add default via 120.52.139.25 dev eth0 src 120.52.139.30 table cnc
ip rule add from 120.52.139.30 table cnc
ip route add default via 123.58.236.1 dev eth1 src 123.58.236.11 table tel
ip rule add from 123.58.236.11 table tel
ip route add default via 112.35.19.33 dev eth2 src 112.35.19.38 table yd
ip rule add from 112.35.19.38 table yd
[[email protected] ~]#