Implement multiple ADSL bindings Based on Linux-Linux Enterprise Application-Linux server application information. The following is a detailed description. Nowadays, many companies tend to give up such high-priced links as E1 to save costs and choose low-cost ADSL as the basic access method. A single ADSL has limited bandwidth, dynamic IP addresses, and unstable link connections. Multiple ADSL instances can meet certain bandwidth requirements, but generally multiple gateways are configured on the Intranet. The intranet users manually specify the gateway to select the ADSL egress, Which is cumbersome for management and maintenance. Some ADSL access providers provide ADSL multi-link bandwidth bundling services by supporting MPPP, but they will also charge a relatively high fee. Here we will introduce a method to bind multiple ADSL links through Linux gateway.
A necessary condition is that an external Linux host can be accessed quickly through ADSL. Generally, you can select the host hosting service provided by the local data center. Here we can do a simple speed test. You can use FlashGet to download files from the host through ADSL to occupy the bandwidth of the slow ADSL.
First, let's briefly introduce the principle. First, create a basic tunnel through ppp over ssh. Then, multiple tunnel is aggregated through Linux's support for mppp. The remaining question is how to make full use of multiple existing ADSL gateways. The answer is to use the ssh-B parameter to specify the source ip address, and then use the linux source routing to select a specific gateway.
First, create a common user on LE and configure ssh key verification.
# Groupadd adslin
# Useradd-g adslin-m adslin
Use ssh-key on LG to create a key file
# Ssh-key-t dsa-f/etc/ppp/peers/adsl-out-key
Then copy/etc/ppp/peers/adsl-out-key.pub to LE ~ In the adslin/. ssh/authorized_keys file. Note that the owner must be adslin: adslin.
Perform a test to ensure that ssh can log on to LE without entering the password.
# Ssh-I/etc/ppp/peers/adsl-out-key adslin @ LE
After confirming that everything is correct, let's continue.
The following work is done on LE:
1. Copy the pppd of the system to the adslin HOME directory and set this attribute correctly.
# Cp/usr/sbin/pppd ~ Adslin
# Chmod u + s ~ Adslin/pppd
2. Prepare the password verification file and add two lines to the/etc/ppp/chap-secrets file.
Adslin adslout 123456 *
Adslout adslin 123456 *
(Actually, only one row is required, and I am not sure which line works)
3. Create an adslin file in the/etc/ppp/peers directory. The content is as follows:
-- BEGIN --
Endpoint phone: 144145
Name adslin
Remotename adslout
Netmask 255.255.255.0
1.2.3.4: 4.3.2.1
Multilink
Nodetach
+ Chap
Require-chap
-- END --
Here, the endpoint and multilink must be modified to support mppp. netmask and ip addresses.
The following work is completed on LG.
1. Add the same two rows to/etc/ppp/chap-secerts as the operations on the preceding LE.
2. Create an adslout file in the/etc/ppp/peers/directory. The content is as follows:
-- BEGIN -- endpoint phone: 144145
Name adslout
Remotename adslin
Netmask 255.255.255.0
4.3.2.1: 1.2.3.4
Multilink
Nodetach
+ Chap
Require-chap
Pty "ssh-t-I/etc/ppp/peer/adsl-out-key adslin @ LE./pppd call adslin"
-- END --
As you can see, this file is basically the same as adslin on LE, except for name/remotename and ip address reconciliation. The pty option is added, and pppd uses the command line provided by this option to establish a connection pipeline.
Finally, let's test it and run it on LG.
# Pppd call adslout
Check whether a normal ppp connection can be established based on the ssh link.
The current job is to prepare a policy route. We all know that the routing rules of the standard IP address are based on the destination address. For a same destination address, how can we control TCP connections and select different gateways? First, let's look at the example below in detail.
# Ip addr add 192.168.1.201/24 dev eth0
# Ip rule add pref 12001 from 192.168.1.201 table 101
# Ip route add default via 192.168.1.1 table 101
# Ip addr add 192.168.1.202/24 dev eth0
# Ip rule add pref 12002 from 192.168.1.202 table 102
# Ip route add default via 192.168.1.2 table 102
In a simple explanation, ip addr add adds an ip address to the eth0 interface. Ip rule add adds a policy. All ip packets whose source address is 192.168.1.201 use the table 101 route table instead of the default system route table. Ip route add adds a default route, which is added to table 101 instead of the default system route table.
In other words, if the source IP address is 192.168.1.201, the route table 12001 will be queried Based on the 12001 (pref 101) rule. The gateway of the 101 route table is 192.168.1.1. Similarly, if the source address is 192.168.1.202, 192.168.1.2 is selected as the gateway. Now we understand that we can control the specific gateway selection by controlling the source address. But how can we control the IP packet source address?
Man ssh, we can see that the-B option, bind address, right, is this option. Ssh-B 192.168.1.201... will use the 1.1 gateway. ssh-B 192.168.1.202... will establish a connection through the 1.2 gateway. We can use the-B parameter to control the source address of the connection and select the gateway used for the connection.
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