How to configure multi-line ADSL in Linux

How to configure multi-line ADSL in Linux

This document can explain the configuration process of dual ADSL and multi-ADSL adding lines.
The method of configuring multi-line ADSL in Linux
powered by KindGeorge http://kindgeorge.at.3322.org\ After a period of observation, it has been proved that it works well. Now I will summarize the setting process and method. Corrections are welcome.
This document can explain the dual adsl And the configuration process of adding multiple adsl lines.
Experimental environment:
operating system: RedHat7.3
two adsl, long-term observation of line stability, dynamic ip, bandwidth 2M,
three network cards: eth0 tulip, connected to the intranet
eth1 3c59x, connected to the first one adsl
eth2 8139too, connect to the second adsl
ethn xxxx, (if there is any....)
Purpose: use two adsl to surf the Internet together, share the load, achieve general simple load balancing, and drive the intranet.
1. Add Network card
Insert the network card and start the machine. If you need dual-line Internet access, you need three network cards. You can also refer to other information to configure the network card.
Configure to find the corresponding model module, for example: eth2 is the network card of 8139
[root@kindgeorge root]# vi /etc/modules.conf
alias parport_lowlevel parport_pc
alias eth0 tulip
alias eth1 3c59x
alias eth2 8139too Insert
the new line on eth2
2. Configure adsl
method 1:
(1) Run the adsl-setup program, it will prompt you to complete the configuration step by step.
Create the dial-up configuration files of ppp0 and ppp1, and save the configuration, Generally saved in /etc/sysconfig/network-scripts/ifcfg-ppp1
(2) Determine the /etc/sysconfig/network-scripts/ifcfg-ppp0 file, where the PIDFILE parameter is set to:
PIDFILE=/var/run/ppp-adsl .pid
Modify the /etc/sysconfig/network-scripts/ifcfg-ppp1 file and set the PIDFILE parameter to:
PIDFILE=/var/run/ppp-adsl1.pid
If you have more lines, you can continue to increase 0, 1, 2, 3.... etc.
This is to make it easier for different dials to use different pids. If this parameter is not modified, the second line interface cannot be started.
(3) The configuration file is generally:
USERCTL=no BOOTPROTO=dialup NAME=DSLppp1 DEVICE=ppp1 TYPE=xDSL ONBOOT=yes PIDFILE=/var/run/pppoe-adsl1.pid FIREWALL=NONE PING=. PPPOE_TIMEOUT=20 LCP_FAILURE=3 LCP_INTERVAL=20 CLAMPMSS=1412 CONNECT_POLL= 6 CONNECT_TIMEOUT=60 DEFROUTE=yes SYNCHRONOUS=no ETH=eth2 (network card corresponding to the new line) PROVIDER=DSLppp1 USER=new user name provided by isp 2 PEERDNS=no
Method 2:
(1) Directly copy
cp /etc/sysconfig/network -scripts/ifcfg-ppp0 /etc/sysconfig/network-scripts/ifcfg-ppp1
(2) Modify ppp0 to ppp1,
modify PIDFILE=/var/run/pppoe-adsl.pid to PIDFILE=/var/run/pppoe -adsl1.pid
modify the network card used for the new line, for example: change ETH=eth1 to ETH=eth2
(3) Add the account and password of the new line. The account and password are generally saved in /etc/ppp/chap-secrets and pap -secrets
We only need to add a new username 2 and password 2 at the end. The
/etc/ppp/chap-secrets file generally looks like this:
# Secrets for authentication using CHAP
# client server secret IP addresses
"username1" * "password1"
"username2" * "password2"
"usernamen" * "passwordn"
3. Start the ppp interface
because the adsl-start command can only Start the first ppp interface. So to start two interfaces, a configuration file must be specified.
You can use: Method 1:
ifup ppp0
ifup ppp1
(ifup pppn...)
or Method 2:
adsl-start /etc/sysconfig/network-scripts/ifcfg-ppp0
adsl-start /etc/sysconfig/network-scripts/ifcfg- ppp1
(adsl-start /etc/sysconfig/network-scripts/ifcfg-pppn)
4. Check whether the new settings are activated:
Method 1: Execute: ifconfig
appears ppp0 and ppp1, and both get ip. It means that it is successful, and the result is like this :
ppp0 Link encap:Point-to-Point Protocol inet addr:218.114.37.137 P-t-P:61.142.110.30 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1 RX packets:165721 errors:0 dropped:0 overruns:0 frame:0 TX packets:123673 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:3 RX bytes:157324193 (150.0 Mb) TX bytes:14068892 (13.4 Mb)
ppp1 Link encap:Point-to-Point Protocol inet addr:218.114.35.62 P-t-P:61.142.110.30 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1 RX packets:560055 errors:0 dropped:0 overruns:0 frame:0 TX packets:439711 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:3 RX bytes:530025378 (505.4 Mb) TX bytes:80895162 (77.1 Mb)
方法二: 执行ip高级命令: ip link ls
也可以检验ppp0和ppp1,结果象这样:
1: lo: mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: mtu 1500 qdisc pfifo_fast qlen 100 link/ether 00:50 :bf:07:4e:32 brd ff:ff:ff:ff:ff:ff 3: eth1: mtu 1500 qdisc pfifo_fast qlen 100 link/ether 00:01:02:9a:31:b9 brd ff:ff:ff :ff:ff:ff 4: eth2: mtu 1500 qdisc pfifo_fast qlen 100 link/ether 00:e0:4c:79:44:71 brd ff:ff:ff:ff:ff:ff 268: ppp1: mtu 1492 qdisc pfifo_fast qlen 3 link/ppp 273: ppp0: mtu 1492 qdisc cbq qlen 3 link/ppp
Method 3: Test the response with the command
ping -I ppp0 202.96.134.133 (test the line condition of ppp0)
ping -I ppp1 202.96.134.133 (test the ppp1 Line status)
ping -I ppp2 ......n (if there are more than one)
5. If only to achieve link load balancing, let ppp0 and ppp1 share the load, then we set the configuration as follows:
( 1) Start routing to allow forwarding echo 1 > /proc/sys/net/ipv4/ip_forward
(2) for masquerading:
iptables -A POSTROUTING -t nat -s 192.168.1.0/24 -o ppp0 -j MASQUERADE
iptables -A POSTROUTING -t nat -s 192.168.1.0/24 -o ppp1 -j MASQUERADE
iptables -A POSTROUTING -t nat -s 192.168 .1.0/24 -o pppn -j MASQUERADE (if there are more than one)
(3) Modify the gateway
ip route replace default scope global nexthop dev ppp0 weight 1 nexthop dev ppp1 weight 1
Description: The reason for using replace is when there is no gateway This gateway will be added when there is a gateway. When a gateway already exists, the original gateway will be modified.
You can also use add, but when a default gateway already exists, you must delete it first and then add it.
The two weights of 1 mean that the two links The weights are equal, and the network traffic borne by the two links is equal.
One thing needs to be explained, because the routing table is based on cache, so in practice, the two links cannot share the traffic 100% equally
. Nexthop NEXTHOP sets the next hop address of multi-path routing. NEXTHOP is more complex, its syntax is similar to the following high-level parameters:
via ADDRESS--represents the next hop router;
dev NAME--represents the output device;
weight NUMBER--in the multi-routing path, the weight of this element. Indicates relative bandwidth or quality of service.
If you have multiple lines, then continue to add nexthop dev ppp2 (ppp3...) to it
(4) refresh the route
ip route flush cache
6. Check the direction of the data immediately
Use tcpdump to monitor the two lines respectively, Use the following command:
tcpdump -i ppp0 tcpdump -i ppp1 tcpdump -i ppp2......n (if there are multiple)
7. In order to automatically start each time, write the command in the startup script, in /etc Add after /rc.local:
ifup ppp0 ifup ppp1 echo 1 > /proc/sys/net/ipv4/ip_forward iptables -A POSTROUTING -t nat -s 192.168.1.0/24 -o ppp0 -j MASQUERADE iptables -A POSTROUTING -t nat -s 192.168.1.0/24 -o ppp1 -j MASQUERADE ip route replace default scope global nexthop dev ppp0 weight 1 nexthop dev ppp1 weight 1 ip route flush cache
Result: Running for several months, the effect is stable and good.
Internet access will be significantly faster, why? Because the two lines share the load. For example, if 80 people surf the Internet at the same time, if the network is a 2M adsl, the entire line will be crowded and crowded. The bandwidth may only be 30k. Everyone will obviously feel that the Internet is very slow.
If one more line is added, the two 2M will share the congestion level together, so that the bandwidth shared by each person may become 60K, which is double the original. In this way, the Internet speed is accelerated and the number of concurrent connections is increased. number.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326425639&siteId=291194637