Setting PPP dial-up Internet access in Linux

Source: Internet
Author: User
Tags domain name server nameserver

Since it is a dial-up Internet access, we cannot skip the Point-to-Point Protocol. the PPP protocol provides a way to transmit data packets through a serial point-to-point connection. it consists of three parts: an extended Connection Control Protocol (LCP) and a Family Network Control Protocol (NCP) used to establish and configure different network layer protocols. the encapsulation scheme is provided by the kernel driver code. pppd (PPP Daemon) provides basic LCP, authentication support, and Network Control Protocol (NCP) for creating and configuring IP addresses. a ppp session is divided into four steps: Connection establishment, connection quality control, Network Layer Protocol configuration, and connection termination. A password authentication protocol (PAP) or an invitation Handshake Authentication Protocol (CHAP) are provided) to ensure connection security. with PPP, you can connect your Linux PC to a PPP server and access the network resources connected to the server, just as you are directly connected to the network. You can also set your Linux PC as a PPP server so that other computers can dial your computer and access resources in your regional network.

Of course, for our end users, it is an application of the server/client model. This article mainly discusses how the client performs dial-up Internet access. After all, PPP is an important part of daily life for desktop users. Here, I think you may be deeply "admired" for the ease of use of the dial-up adapter in windows. I don't want to discuss it here, the TAPI provided by Microsoft makes it not difficult for every programmer in Windows to write a dialing program. What about Linux? Whether it is wvdial in GNOME or kppp in Kde, they are more direct and easier to operate than pure script PPP-on, and they are not too good to call graphical dial-up scripts, because they eventually call the powerful but difficult-to-handle pppd program. Someone told me that kppp is similar to the dial-up adapter in windows, but I want to tell you that kppp is more dependent on pppd programs than kppp is used as an independent dial-up program, even the option values under/etc/PPP/options cannot be ignored.

Script dialing process in Linux: (it can be applied to all dialing processes in Linux. Of course, the actual process is not that simple. If you are interested, please read the source code)

1. The pppd program calls the chat session program.
2. the chat session program is responsible for dialing, starting the pppd program on the server, verifying the identity, and then the chat session program ends.
3. The pppd program continues the chat session program, shakes hands with the pppd program on the server, and establishes a PPP connection.

The PPP-on script contains the pppd program, while the PPP-on-dialer script contains the chat session program, if the pppd program completes connection establishment, connection quality control, Network Layer Protocol configuration, and connection termination, then the chat program completes textword verification, if the incoming server requires a password authentication protocol (PAP) or invites a handshake authentication protocol (CHAP) to ensure connection security, you must configure the pap-secrets or chap-secrets file in the/etc/PPP directory.

Configuration of pure script dialing for PPP-on and PPP-on-dialer

A complete PPP-on file is as follows: (the instance and PPP-on-dialer files here are all taken as an example)

Telephone = 163 # Internet phone number provided by the ISP
Account = 163 # account name
Password = 163 # logon Password
Local_ip = 0.0.0.0 # local IP address. 0.0.0.0 indicates that the local IP address is dynamically allocated by the ISP.
Remote_ip = 0.0.0.0 # remote IP address, usually 0.0.0.0
Netmask = 255.255.255.0 # Subnet Mask
Export telephone account password/
Dialer_script =/etc/PPP-on-dialer/
Exec/usr/sbin/pppd lock modem crtscts/dev/ttys0 115 ***/
Asyncmap 0 kdebug 4/
$ Local_ip: $ remote_ip noipdefault netmask $ netmask defaultroute/
Connect $ dialer_script &

Note the following:
A. Note: "/" indicates the end of a complete row.
B. Set the level of kdebug to a higher level, because the file/var/log/messages details are determined based on the level of kdebug.

A complete PPP-on-dialer file is as follows:

Exec chat-V/
Timeout 3/
Abort '/nbusy/R '/
Abort '/Nno answer/R '/
Abort '/nringing/R/n/R/nringing/R '/
Abort '/nusername/password incorrect/R'/this line can shorten the verification time due to incorrect account and password.
''/Rat/
'OK-++/C-OK' ATH0/
Timeout 30/
OK atdt163/
Sername: -- sername: 163/
Assword: 163/

Are the above configurations correct? File configuration is correct, but there are many problems. Let me analyze the problem in detail (premise: no matter the cat inside the cat is installed, check the command: Echo "Echo atdt 163">/dev/modem ), in the/etc/PPP directory, type. /The following error occurs after the PPP-on command:

1. tr bright, no dialing sound.

Solution:

First, check the permission of the PPP-on-dialer file and set it to chmod 7 PPP-on-dialer.
Check whether the PPP-on-dialer file exists after each line.
Check whether the phone number of OK atdt $ telephone in the last row is set correctly. Note that the actual phone number must be set here, not a variable.

2. The following prompt appears in the/var/log/messages file:
21:13:32 Ken pppd [657]: CCP terminated by peer
21:13:32 Ken pppd [657]: compression disabled by peer.
Or the prompt "Connect scripts fail" appears directly (the following prompt appears after N times)

Note: The chat-V in the PPP-on-dialer file indicates that the session information of the client and the server is written to the/var/log/messages file through syslogd, if you want to view the session information, type tail-F/var/log/messages or tailf/var/log/messages. This information is useful for configuring the dialing script file correctly.

Solution:

First, check whether the account password is correct.
Then it may be a problem with the chat session program itself. Let's take a look at the example below:

Tips for Chengdu Tianfu hotline 163 at minicom:
**************************************** *******
* Quidway a8010 Internet Server
* Welcome !!
**************************************** *******
Please input Username:

Please input password:

Tips for Chengdu Tianfu hotline 169 at minicom:
* ** Welcome to Tianfu online EeYing01-11! ***
Login:
Password:

You may have noticed something different! That is, different dial-up servers may have different account and password input prompts. If you have used a Windows dial-up terminal, you may know why Windows dial-up does not have this problem, because it is a problem with the chat program itself: the account and password cannot be sent based on the account and password prompts of the dial-up server. Solution: Use minicom to get the correct prompt, the root tool prompts you to modify the configuration of the last two lines of the PPP-on-dialer file. Here, the prompt of Chengdu Tianfu hotline 163,169 at minicom is used as an example:

163:
Sername: -- sername: 163/
Assword: 163/

169:
Ogin: -- ogin: liujien/
Assword: liujien/

Is this all done? No, the configuration here should be based on your ISP's requirements (hint), use minicom n times to get the correct prompt, however, you may be at risk of modifying the account and password of your ISP, So I advise you to abandon the chat session program. Because kppp and wvdial do not have this problem. the chat session program is force, while wvdial and kppp are guess. with this problem I read the ppp-2.4.1 source code documentation, in fact the author has been in the ppp-2.3.11 version has provided plugins passprompt (Note: ppp-2.3.10 version has provided plug-in support, home redhat6.2 comes with a ppp-2.3.11 RPM package, as to the plug-in general domestic Linux site provided on the PPP source package are included ), this plug-in provides a third-party program with the call function to send the account and password to your ISP. The related content is as follows:

A new 'passprompt' plugin is supported ded, thanks to Alan curry, which makes it possible for pppd to call an external program to get the PAP password to send to the peer.

So how to use this plug-in? Compile the passprompt. c file in the directory containing the pppd. h header file.
Gcc-c-o passprompt. c
Gcc-shared-O passprompt. o
You can get a passprompt. copy the shared link file of so to the/etc/PPP/Plugins directory, modify the/etc/PPP/options file, and add a line of plugin/etc/PPP/plugins/passprompt. so, then you can modify the PPP-on file to direct dialer_script to the script file you want to specify. You can compile a program or download a third-party program online.
I provide you with a simple method. you can install the wvdial dialup program, and then run/etc/wvdial in gnome. after configuring the conf file, create a script in the/etc/PPP directory named wvdial. The content is as follows: wvdial 163 (163 is the phone number you want to dial), and then chmod 7 wvdial, modify the PPP-on file, for example, dialer_script =/etc/PPP/wvdial/

3. The client has obtained an IP address (which can be viewed using the ifconfig command). You cannot browse the webpage through the domain name, but you can use the IP address.

Solution:
General method: Check the manual provided by the ISP to obtain the IP address of the Domain Name Server and modify/etc/resolv. the conf file is as follows: nameserver 61.139.2.69 (take Chengdu 163 as an example). You can also use the ipconfig/all command in Windows to get the DNS server address, because the dial-up program in Windows is set: automatically obtain the DNS server address.

The methods provided by the software author:
What was new in ppp-2.3.6.
**************************
Added new option 'usepeerdn', thanks to Nick Walker. if the peer supplies DNS addresses, these will be written to/etc/PPP/resolv. conf. the IP-up script can then be used to add these addresses to/etc/resolv. conf if desired (see the ip-up.local.add and ip-down.local.add files in the scripts directory ).

The software author provides an option similar to a Windows dialup program in ppp-2.3.6: usepeerdns. If your ISP provides the DNS server address, it will be in/etc/PPP/resolv. CONF file and/etc/resolv. the main Domain Name Server address and the secondary Domain Name Server address are written in the conf file, as follows:
Nameserver 61.139.2.69
Nameserver 202.103.4.5
How to Set: Modify the/etc/PPP/options file and add a "usepeerdns" Line"

Postscript:
Here, I did not discuss Linux script dial-up surfing in depth, but I analyzed several common problems and provided a simple solution. I hope you can read some of the English instruction documents provided by the software authors because some documents in China are too old to read man pages without patience. They are very useful, reading articles from some websites is not a good choice. If you have different opinions on my article, please write to me. Thank you.

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.