Linux Telecom China Netcom dual-line policy-Linux Enterprise Application-Linux server application information. The following is a detailed description. I have collected a complete IP subnet allocation table for China Netcom. I used a calculator to convert the subnet mask in dotted decimal format into a unix bit representation, it's easy to implement it through a program. Some programmers in the company told me later that they admire programmers.
The implementation method is as follows: three NICs, eth0 is the LAN port, eth1 is the first WAN port, connect to the telecom line, eth2 is the second WAN port, and connect to the Netcom line. I have configured the IP address based on the fixed IP address. If you want PPPOE, configure the PPPOE part by yourself. Here I will mainly provide you with the policy part.
MASQUERADE
/Sbin/iptables-t nat-a postrouting-o eth1-j MASQUERADE
/Sbin/iptables-t nat-a postrouting-o eth2-j MASQUERADE
Then, add a route table marked as 100 to the system and a default gateway, which is the gateway provided by China Netcom. Why is the total number of Route tables in my post 100.
Ip route add 0/0 via 218. 59. *. * table 100
Configure the gateway for the system's main route table. The Gateway is a telecom gateway.
Ip route add 0/0 via 219. 146 .*.*
Then, add a routing rule to mark all the data queries to China Netcom as 100 route tables:
Ip rule add to 60.0.0.0/13 table 100
Ip rule add to 60.8.0.0/15 table 100
Ip rule add to 60.10.0.0/16 table 100
..........
There are many rules. There are more than 100 rules. It should be the complete IP address subnet of China Netcom. I will give the complete rules.
In this way, data destined for China Netcom will query route table 100, while data destined for other places will be directed to China Telecom if China Telecom is specified here. Of course, if there are more complex applications, such as the educational network line, I believe everyone knows how to do it, and then add a route table and a policy.
This configuration method has been used by friends in the north. I hope it will be helpful to you. Note that When configuring the network card, do not configure the gateway, do not use the old ifconfig command to configure the gateway, but use iproute2 to configure the gateway. Otherwise, a conflict may occur, alternatively, use the ip route replace command to replace the ip route add command.
The configuration file is as follows: (the configuration of port filtering is not included. You can configure the configuration as needed.) Actually, attachments can only be uploaded in jpg and gif. I added a. jpg extension to the footer and right-clicked the file to remove it, change it back.