Linux dual network card dual ip-dual external network gateway-telecom Unicom dual line host settings

1. Realization: Through the intelligent DNS provided by the operator, when the telecommunications users access, the data enters the telecommunications network card, and also comes out from the telecommunications gateway, when accessing Unicom, from the Unicom network card, the Unicom network card. In this way, the speed will be fast, and the function of the two-line host will be realized.

2. Network card information:
Telecom IP (TEL): 114.80.0.4 netmask 255.255.255.128 gateway 114.80.0.3
Unicom IP (CNC): 112.65.0.2 netmask 255.255.255.0 gateway 112.65.0.1

3. vi / etc / iproute2 / rt_tables, add two routing tables for Netcom and Telecom
251 tel telecommunication routing table
252 cnc network routing table

4. Set the telecommunications routing table
ip route flush table tel
#Clear routing table ip route add default via 114.80.0.3 dev eth0 src 114.80.0.4 table tel 
ip rule add from 114.80.0.4 table tel

5. Set Unicom's routing table
ip route flush table cnc 
ip route add default via 112.65.0.1 dev eth1 src 112.65.0.2 table cnc 
ip rule add from 112.65.0.2 table cnc

6. Configure the network startup script file to add the following before the end of exit 0:
# vi /etc/rc.d/init.d/network

ip route flush table tel 
ip route add default via 114.80.0.3 dev eth0 src 114.80.0.4 table tel 
ip rule add from 114.80.0.4 table tel

ip route flush table cnc 
ip route add default via 112.65.0.1 dev eth1 src 112.65.0.2 table cnc 
ip rule add from 112.65.0.2 table cnc

exit 0

7. Restart the system or the network may fail, please add the startup script:
If it is ubuntu / debian, the system startup script is /etc/rc.local 
If it is RedHat / centos, the system startup script is /etc/rc.d/rc.local

If it is ubuntu / debian, the network startup script is /etc/init.d/networking 
If it is RedHat / centos, the network startup script is /etc/rc.d/init.d/network

Guess you like

Origin www.cnblogs.com/Crazy-Liu/p/12761299.html