1、3 Line 3 IP server interface IP address (vlan interface)
em1.12 Single Unicom: 120.52.139.9 Mask: 255.255.255.240 Gateway: 120.52.139.1
em1.13 Single Telecom: 123.58.236.26 Mask: 255.255.255.248 Gateway: 123.58.236.25
em1.16 Single mobile: 223.71.150.91 Mask: 255.255.255.248 Gateway: 223.71.150.89
2、 Configure routing table labels
test@ubuntu:~$ cat /etc/iproute2/rt_tables
255 local
254 main
253 default
0 unspec
#( (Add the following Unicom, Telecom, Mobile routing tags)
252 cnc
251 ct
250 yd
3、 Configure routing table and routing strategy
sudo ip route add table cnc via 120.52.139.1 dev em1.12 src 120.52.139.9
sudo ip rule add from 120.52.139.9 table cnc
sudo ip route add table ct via 123.58.236.25 dev em1.13 src 123.58.236.26
sudo ip rule add from 123.58.236.26 table ct
sudo ip route add table yd via 223.71.150.89 dev em1.16 src 223.71.150.91
sudo ip rule add from 223.71.150.91 table yd
4、 Write routing table and routing strategy to start automatically
test@ubuntu:~$ sudo cat /etc/rc.local
#! /bin/sh -e
sudo ip route add table cnc via 120.52.139.1 dev em1.12 src 120.52.139.9
sudo ip rule add from 120.52.139.9 table cnc
sudo ip route add table ct via 123.58.236.25 dev em1.13 src 123.58.236.26
sudo ip rule add from 123.58.236.26 table ct
sudo ip route add table yd via 223.71.150.89 dev em1.16 src 223.71.150.91
sudo ip rule add from 223.71.150.91 table yd
Recommended Posts