Advanced Linux Routing and Traffic control: Multi-NIC Load Balancing

Source: Internet
Author: User
Keywords Linux load balancing flow control multiple network adapters advanced routing
Tags advanced advanced routing aliyun control directions function html http

There are several ways to achieve this function. One of the simplest and most straightforward methods is "TEQL"-True (or "normal") link equalization. Like most things done with queues, http://www.aliyun.com/zixun/aggregation/13996.html "> Load balancing also needs to be implemented in both directions." Both ends of the link must be involved to have a complete effect.

Imagine the following:

A and B are routers, and we certainly assume that they are all Linux machines. If the traffic from Network 1 to Network 2 requires a router to use two links to the B router at the same time. The B router needs to be configured to accommodate this situation. The same is the reverse transmission, when the packet from the network 2 to the network 1 o'clock, b routers use both eth1 and eth2.

The assigned function is implemented with the "TEQL" device, like this (Nothing is simpler):

# TC Qdisc Add dev eth1 root teql0
# TC Qdisc Add dev eth2 root teql0
# IP link set dev teql0 up

Don't forget the IP link set up command!

This is done on both machines. The teql0 device is essentially a wheel forwarding frame between eth1 and eth2. The source will not have data from the TEQL device to come in, just appear in the original eth1 and eth2.

We now have a network device and we need to have a proper route. One way to do this is to assign a network of two links to one/31, Teql0:

On a router:

# IP addr Add dev eth1 10.0.0.0/31
# IP addr Add dev eth2 10.0.0.2/31
# IP addr Add dev teql0 10.0.0.4/31

On the B router:

# IP addr Add dev eth1 10.0.0.1/31
# IP addr Add dev eth2 10.0.0.3/31
# IP addr Add dev teql0 10.0.0.5/31

A router should now be able to ping 10.0.0.1, 10.0.0.3, and 10.0.0.5 through 2 real links and a balanced network card. The B router should be able to ping the 10.0.0.0, 10.0.0.2 and 10.0.0.4.

If successful, a router should use 10.0.0.5 as a route to Network 2, and B routers should take 10.0.0.4 as a route to network 1. When network 1 is your home network, and Network 2 is the Internet, the default gateway for a router should be set to 10.0.0.5.

Warned

Things will never be as simple as they seem. Eth1 and eth2 on router A and B routers need to turn off "return path filtering", otherwise they discard packets that return addresses that are different from their source addresses:

# echo 0 >/proc/sys/net/ipv4/conf/eth1/rp_filter
# echo 0 >/proc/sys/net/ipv4/conf/eth2/rp_filter

The messy sequence of packages is also a big problem. For example, there are 6 packets that need to be sent from a to b,eth1 may be divided into 1th, 3, 5 packages, and eth2 to 2nd, 4, 6. Ideally, the B router will receive 1th, 2, 3, 4, 5, and 6th packets sequentially. But in fact, the kernel of the B router is likely to receive packages in random order like 2, 1, 4, 3, 6, 5. This problem will confuse TCP/IP. Although it is not a problem to host different TCP/IP sessions on the link, you cannot increase the download speed of an FTP file by bundling multiple links, unless the operating system on both ends is Linux, because Linux's TCP/IP protocol stack is not so easily blinded by this simple problem of chaos.

Of course, the load balancing of links is a good idea for most application systems.

Other possibilities

William Stearns has taken advantage of advanced tunnels to bundle the effects of multiple Internet connections. Can be found on his tunnel web page.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.