Linux Dial-up tool: Wvdial and pppd--reprint

Source: Internet
Author: User

WVDial is Linux Smart Dial-up tools, using wvdial and PPP, allows easy Internet access under Linux. Throughout the process, the role of wvdial is to dial and wait for the prompt, and according to the prompts to enter the appropriate user name and password authentication information; The role of PPP is to negotiate with the dial-in party the method of transmitting data and maintain the connection.

First, wvdial and its related configuration
wvdial is powerful, tempted to guess how to dial and log on to the server, and it also handles common error intelligence, unlike chat, which requires you to write a logon script. wvdial has only one configuration file:/etc/wvdial.conf.

  The boot process for wvdial is like this: you first need to load the wvdial.conf configuration file, then initialize the modem and Dial

number, wait for the dial-in response after dialing, and then start PPPD after receiving the dial-in response. can be automatically generated with the WVDIALCONF program

wvdial.conf configuration file, run the program in the following format:

Wvdialconf/etc/wvdial.conf

During the execution of the program, the program automatically detects the configuration of your modem, including the available device file names,

Modem baud rate, initialize characters and other related dialing information, and automatically generate wvdial.conf configuration file based on this information.

If the/etc/wvdial.conf file already exists, executing the command again will only change the Modem, Band, init, etc.

Item A typical auto-generated configuration file might be like this


[Dialer Defaults]
Modem =/dev/ttyacm0
Baud = 115200
Init1 = ATZ
Init2 = ATQ0 V1 E1 s0=0 &c1 &d2 s11=55 +fclass=0
; Phone =
; Username =
; Password =

The execution format for wvdial is: wvdial-help | -version | Section
The relevant instructions are as follows:
-help: Display simple help information
-version: Displays the version number of the wvdial
Section: Here the section is a bit like the INI file in Windows, a wvdial.conf configuration file can have a lot of sections, each section consists of a number of variables, that is, the variable = value of the statement, as shown above. Using wvdialconf to automatically generate a configuration file will automatically generate some commonly used variable descriptions as follows:inherits=inheritedsection:
[Dialer Defaults] is automatically generated when the configuration file is automatically generated using wvdialconf, and you can customize your own section. When the program runs, it first loads [Dialer Defaults] and then overrides the appropriate options for [Dialer Defaults] with the appropriate options for the specified section. For example, we also have [Dialer Tom] in wvdial.conf, and if we run Wvdail Tom, the system will first read [Dialer Defaults] and then use [Dialer Tom] to override the [Dialer Defaults] option. If there are [Dialer 169] In addition to the section above, the contents are as follows:

[Dialer Tom]
Username=tom
password=xxx
inherits=169
[Dialer 169]
phone=169

If we execute "wvdial Tom" at this time, the system will read [Dialer Defaults] and then use [Dialer Tom] to overwrite [Dialer Defaults] options, and then use [Dialer 169]. Options to overwrite the previous options. This shows that with wvdial, we can easily move back and forth between different ISPs or modems (if you have several ISPs or medom).
Modem=/dev/ttysx: Used to specify the Modem, the default is/dev/modem. Of course, here our medom is automatically detected and configured by wvdialconf, so we can ignore the variable.
Band=115200:wvdial the baud rate of communication with modem, as above can be ignored.
Area code=xxxx: Set code
Dial prefix=x: If you are using an extension, dial 9 o'clock for an external line, and you can set the value to 9.
Username=xxxx: User name at logon
password=xxxxxx: login password
phone=xxxxx: dialed number
PPPP path=: Set pppd path, default =/usr/sbin/ PPPD
Force address=x.x.x.x: Set up a static IP, a generic ISP will assign you a dynamic IP address.
New pppd= 1 or 0:PPPD 2.3.0 and above require/etc/ppp/peers/wvdial files, if your PPPD is 2.3.0 or later please set to 1.
Auto Reconnect=on: Whether to automatically reconnect when the line is disconnected, by default set to Yes.
The above is just the usual option in wvdial.conf, refer to wvdial manual for details.

II, PPPD and its related configuration
PPPD configuration options are relatively more complex, you can refer to the options in the form of a command line, or you can write the options you want to refer to in/etc/ppp/options. The following sample file contains the most common options and their associated descriptions:
# If no local IP is given, PPPD will use the first IP address of the host;
# If you specify the "noipdefault" option, PPPD will use the IP address provided by the dial-in

# Select this option, PPPD will accept the IP address provided by the Dial-in party: ipcp-accept-local
# Select this option, PPPD will accept the dial-in side's own IP address: ipcp-accept-remote
# Set Default gateway: Defaultroute
# before transmitting the packet, let the dial-in party first self-authentication, note that the general ISP (such as 169, 163) does not include the machine # system, it should be selected Noauth
# Using hardware flow control: crtscts
#将拨号信息作日志: Debug
These are just a few of the options that are commonly used, refer to the PPPD manual for details.

A city instances
Let's look at a specific application where we automate dial-up and disconnection. The configuration files involved are:
Configuration file for/etc/wvdial.conf:wvdial
Configuration file for/ETC/PPP/OPTION:PPPD
/etc/ppp/ppp-on: Dial Automation script
/etc/ppp/ppp-off: Disconnecting automation scripts
Step One: Ensure the modem is properly connected, Linux has detected and automatically configured the modem
Step two: Run wvdialconf, generate the/etc/wvdial.conf file and modify the following:

[Dialer Defaults]
Modem =/dev/ttyacm0
Baud = 115200
Init1 = ATZ
Init2 = ATQ0 V1 E1 s0=0 &c1 &d2 s11=55 +fclass=0
New pppd= 1
[Dialer Tom]
Phone = 169
Username = Tom
Password = *******


Step Three: Edit and configure/etc/ppp/options as follows:
Noipdefault
ipcp-accept-local
Ipcp-accept-remote
Defaultroute
Noauth
crtscts
Debug

Step four: Writing Automation scripts
1. Dial script/etc/ppp/ppp-on:
#!/bin/sh
# this Script initiates the PPP connections by wvdial
wvdial Tom &

2. Disconnect Automation Script/etc/ppp/ppp-off:
#!/bin/sh
#!stop wvdial
killall wvdial
# If The ppp0 PID file is present and the program is running. Stop it
if [-r/var/run/ppp0.pid]; then
Kill-int ' cat/var/run/ppp0.pid '
echo "PPP link to ppp0 terminated."
Else
echo "ERROR:PPP link is not active on ppp0"
Exit 0
Fi
Exit 1

After you finish editing, execute chmod u+x/etc/ppp/ppp * Change file permissions. When you are done, you will automatically dial when you run/etc/ppp/ppp-on, and the/etc/ppp/ppp-off will automatically disconnect.

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.