双网段设置路由

1. 注册路由表名称

# cat /etc/iproute2/rt_tables 
#
# reserved values
#
255     local
254     main
253     default
97      jiuqi
0       unspec
#
# local
#
#1      inr.ruhep

2. 设置IP地址

# cat ifcfg-eth2:0
DEVICE=eth2:0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.97.9
NETMASK=255.255.255.0

3. 设置路由表内容

# cat route-eth2:0 
default via 10.10.32.200 dev eth2 table jiuqi

4. 设置使用路由表的条件

# cat rule-eth2:0 
from 192.168.97.0/24 table jiuqi pre 5

5. 重启网络

service network restart

ip route list table jiuqi
ip rule list

参考地址

http://coderazzi.net/linux/dual_nic_linux.htm

原文地址:https://www.cnblogs.com/osroot/p/6067802.html