Bind two ISPs and do load balancing, and the bandwidth can be doubled. That is, if we have two ADSL monthly lines, the bandwidth can be changed to 1m!
Do this work, involve two work
1. How to ensure that traffic segmentation is guaranteed: When responding to packets from an ISP, the same ISP is still used. Let us first define some symbols. The name of the first block (IF1 above) is called $ IF1, and the second network card is called $ IF2. The IP address of $ IF1 is then set to $ IP2. Also, the gateway address of the ISP1 is $ P1, and the gateway address of ISP2 is $ P2. Finally, the network address of $ P1 is $ P1_NET, which makes the network address of $ P2 is $ P2_NET. An additional two routing tables, T1, and T2 are created. Add to / ETC / iProute2 / RT_TABLES. Then set up the route in the two routing tables: IP Route add $ P1_NET DEV $ IF1 SRC $ IP1 TABLE T1 IP Route Add Default Via $ P1 TABLE T1 IP Route Add $ P2_NET DEV $ IF2 SRC $ IP2 Table T2 IP Route Add DEFAULT VIA $ P2 TABLE T2 is not big, but it has established a route to the gateway and makes it a default gateway, which is responsible for a separate uplink, and makes these two ISPs as such a configuration.
It should be pointed out that the network route is necessary because it allows us to find the host in that subnet, including the above gateway. Next, we set the "main" routing table. Put the package through the network card directly to the local area network connected to the NIC is a good way. Pay attention to the "SRC" parameter, they can ensure that the correct exit IP address is selected.
IP Route Add $ P1_NET DEV $ IF1 SRC $ IP1 IP Route Add $ P2_NET DEV $ IF2 SRC $ IP2
Then, set your default route: IP Route Add Default Via $ P1
Next, set the routing rule. This is actually routed in what routing tables. You need to confirm whether you have a corresponding source address when you route a packet from a given interface: You need to guarantee that if you already have the corresponding source address, you should put the packet from the corresponding NIC route. Go out: IP rule add from $ ip1 Table T1 IP Rule Add from $ ip2 Table T2
The above command guarantees that all response data will return from the block of the NIC. Now, very basic configuration is completed. This will work for all the processes running on the router, and after IP camouflage, the local LAN will also work. If you don't make a camouflage, then you either have two ISP address space, either you want to cook for one of the two ISPs. Either case, you have to add a rule, and based on the IP address of the Host in the LAN, choose which ISP route from it.
2. The second problem of load balancing is how to load balancing for data flowing out of two ISP. If you have successfully achieved traffic segmentation, this matter is not difficult. With one of the two ISPs as the default route, this time it is setting the default route to multiplex routes. In the default core, this will balance the route of the two ISPs.
This is done below (Based on the previous flow division experiment): IP Route Add Default Scope Global Next Idd Dev $ IF1 Weight 1 Next, Weight 1 This can balance the route of the two ISPs. By adjusting the "Weight" parameter we can specify one of the ISPs above the other. It should be noted that since the equalization is based on routing, the route is buffered, so this equalization is not 100% accurate. That is to say, for a regularly accessed site, always use the same ISP. Further, if you are not satisfied with this, you may need to refer to the following Julian Anastasov's kernel patch: http://www.ssi.bg/~ja/