Dual-adsl dialing in linux

Source: Internet
Author: User
Tags one more line
Linux dual-adsl dialing-Linux general technology-Linux technology and application information. The following is a detailed description. This document describes how to configure dual-ADSL and multi-ADSL lines ......

After a period of observation, it proves that the operation is good. Let's summarize the setting process and method. please correct me.

This document describes how to configure dual-adsl and multi-adsl lines.

Lab environment:

Operating System: RedHat7.3

Two adsl instances, long term observation of line stability, dynamic IP address, bandwidth 2 M,

Three NICs: eth0 tulip, connected to the Intranet

Eth1 3c59x, connected to the first adsl

Eth2 8139too, connected to the second adsl

Ethn xxxx, (if there is still ....)

Objective: To share the load by using two adsl networks to achieve simple load balancing and drive Intranet access.

1. Add a NIC

Insert the network card and start the machine. If you need to access the Internet through dual-line connection, 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 8139 Nic

[Root @ kindgeorge root] # vi/etc/modules. conf

Alias parport_lowlevel parport_pc

Alias eth0 tulip

Alias eth1 3c59x

Alias eth2 8139too

Add new lines to eth2

2. Configure adsl

Method 1:

(1) run the adsl-setup program and you will be prompted to complete the configuration process step by step.

Create a dial-up profile for ppp0 and ppp1 and save the configuration, typically stored in/etc/sysconfig/network-scripts/ifcfg-ppp1

(2) determine the/etc/sysconfig/network-scripts/ifcfg-ppp0 file, where the PIDFILE parameter is set:

PIDFILE =/var/run/ppp-adsl.pid

Modify the/etc/sysconfig/network-scripts/ifcfg-ppp1 file and set the PIDFILE parameter:

PIDFILE =/var/run/ppp-adsl1.pid

If you have more lines, you can continue to add 0, 1, 2, 3... and so on.

This is to enable different Dialers 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

Clampm Ss = 1412

CONNECT_POLL = 6

CONNECT_TIMEOUT = 60

DEFROUTE = yes

SYNCHRONOUS = no

ETH = eth2 (corresponding to the NIC of the new line)

PROVIDER = DSLppp1

USER = new username provided by isp 2

PEERDNS = no

Method 2:

(1) Direct 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 NIC of the new connection path, for example, ETH = eth1 to ETH = eth2.

(3) Add the account and password for the new line. The account and password are generally stored in/etc/ppp/chap-secrets and pap-secrets.

We only need to add the new username 2 and password 2 at the end.

The/etc/ppp/chap-secrets file is generally like this:

# Secrets for authentication using CHAP

# Client server secret IP addresses

"Username 1" * "password 1"

"Username 2" * "password 2"

"Username n" * "password n"

3. Start the ppp Interface

Because the adsl-start command can only start the first ppp interface by default. Therefore, to start two interfaces, you must specify the configuration file.

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 enabled:

Method 1: Run ifconfig

Ppp0 and ppp1 are displayed, and the ip address is obtained. The result is as follows:

Ppp0 Link encap: Point-to-Point Protocol

Inet addr: 218.114.37.20.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)

Method 2: run the ip advanced command: ip link ls

You can also test ppp0 and ppp1 as follows:

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

3: eth1: mtu 1500 qdisc pfifo_fast qlen 100

Link/ether 00: 01: 02: 9a: 31: b9 brd ff: ff

4: eth2: mtu 1500 qdisc pfifo_fast qlen 100

Link/ether 00: e0: 4c: 79: 44: 71 brd 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 using commands

Ping-I ppp0 202.96.134.133 (test the Route status of ppp0)

Ping-I ppp1 202.96.134.133 (test the Route status of ppp1)

Ping-I ppp2... n (if there are more than one)

5. If we only want to achieve link load balancing and share the load between ppp0 and ppp1, We will configure it as follows:

(1) Start the route and allow forwarding of echo 1>/proc/sys/net/ipv4/ip_forward

(2) disguise:

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

Note: replace is used because the gateway is added when no gateway exists. When a gateway already exists, the gateway is changed.

You can also use add. However, if a default gateway already exists, delete the gateway before adding it.

Two weight 1 means that the weights of the two links are equal, and the network traffic of the two links is equal.

One thing to note is that because the route table is based on the cache, in practice, the two links cannot share 100% of the traffic evenly.

Nexthop NEXTHOP sets the next hop address of a multi-path route. NEXTHOP is complex. Its syntax is similar to the following high-level parameters:

Via ADDRESS -- indicates the next hop vro;

Dev NAME -- indicates the output device;

Weight NUMBER -- weight of this element in a multi-route path. Indicates the relative bandwidth or service quality.

If you have multiple lines, add nexthop dev ppp2 (ppp3......) to the lines.

(4) refresh the route

Ip route flush cache

6. Check the data direction in Real Time:

Use tcpdump to monitor two lines, and run the following command:

Tcpdump-I ppp0

Tcpdump-I ppp1

Tcpdump-I ppp2...... n (if there are multiple entries)

7. to automatically start each startup, write the command in the startup script and add it after/etc/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

Results: After several months of operation, the results were stable.

The Internet access is obviously accelerated. Why? Because the two lines share the load, for example, 80 people access the Internet at the same time on the Intranet,

If the network is a 2 m adsl, the entire line will be crowded and the network will be congested. The bandwidth allocated to each person may only be 30 K. Everyone will obviously feel that the Internet access is slow.

If one more line is added, two 2 m lines share the congestion level. In this way, the bandwidth allocated to each person may change to 60 K, which is the original double. In this way, the Internet access speed is accelerated, added the number of concurrent connections.
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.