How to use Linux dial-up Internet access

Source: Internet
Author: User
Article Title: how to use Linux dial-up to access the Internet. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
I. PPP on Linux
In Linux, point-to-Point Protocol PPP is already included. its main body is pppd. if you have already used a Windows 95 or NT dial-up network, you already have basic PPP experience. After the PPP of Windows 95 is connected to the same ISP, the Windows client will automatically provide the IP address and DNS server address, depending on the ISP's situation, while the Linux PPP will not automatically receive the DNS address, this is a difference between Linux and Windows. Therefore, the PPP on Linux requires one more step of DNS configuration after the protocol connection is successful.
  
II. preparation of Kernel
In your Linux system, you must configure the support for PPP in the kernel. If your kernel currently does not support PPP, you need to generate a new kernel that supports PPP. The method for re-compiling the kernel can be viewed in related Howto.
  
3. configure the PPP dial-up network with a script
I first wanted to run pppd to connect to the dial-up network, but soon I found it too troublesome because there were too many options. Later, I found that several PPP dialing program templates have been provided on Linux. you only need to slightly modify these templates to easily connect them to PPP. Based on my experience, the configuration can be completed in 10 minutes if it succeeds.
  
(1) Directory of the dialing program
  
For RedHat 5.0, these dialers (scripts) are under/usr/doc/ppp-2.2.0f/scripts, if you want to use these scripts, you need to copy them to the correct directory, the details are as follows:
Ppp-on: Copy the PPP connection script to/usr/sbin.
Ppp-off: Copy the PPP disconnection script to/usr/sbin.
Ppp-on-dialer: Copy the PPP login session script to/etc/ppp
Ppp-redialer: you can copy the login script of multiple phone numbers to/usr/sbin (not required in this article)
For Slackware users, these scripts have been installed in the correct directory, so there is no need to do anything.
If you cannot find the above file on your system, you can directly cut it in the appendix following this article.
  
(2) create your own dialup program
  
Assuming that we want to connect to the 163 network through PPP, we can use the above script for simple configuration. Although we can directly modify these templates, we recommend that you copy a template for yourself and make modifications on the new one. Therefore, make the following copy:
  
Cd/usr/sbin
Cp ppp-on ppp.163
Chmod + x ppp.163
Cd/etc/ppp
Cp ppp-on-dialer dialer.163
Chmod + x dialer.163
  
In addition, ensure that ppp-off is executable.
  
(3) customize your own dialup program
  
First, edit your ppp.163. you do not need to modify most of the content. you only need to modify the following:
  
TELEPHONE = 163
ACCOUNT =
PASSWORD =
DIALER_SCRIPT =/etc/ppp/dialer.163
  
In addition, in the last line of exec starting pppd, pay attention to provide the serial device file of your Modem (usually COM1/dev/cua0 or/dev/ttyS0, COM2/dev/cua1 or/dev/ttyS1), and set the serial port communication speed (the default value is 38400. for the current high-speed Modem, this speed is too low, can be set to 57600 or more ). The ppp.163 content after completion is:
  
#! /Bin/sh
#
# Script to initiate a ppp connection. This is the first part of
# Pair of scripts. This is not a secure pair of scripts as the codes
# Are visible with the 'Ps' command. However, it is simple.
#
# These are the parameters. Change as needed.
TELEPHONE = 163 # dialing number
ACCOUNT = YourUserName # User name
PASSWORD = YourPassword # PASSWORD. Be sure to restrict others to read this file!
LOCAL_IP = 0.0.0.0 # local IP address. 0.0.0.0 indicates dynamic allocation.
REMOTE_IP = 0.0.0.0 # Original IP address, usually 0.0.0.0
NETMASK = 255.255.255.0 # subnet mask
Export TELEPHONE ACCOUNT PASSWORD
#
# This is the location of the script which dials the phone and logs
# In. Please use the absolute file name as the $ PATH variable is not
# Used on the connect option. (To do so on a 'root' account wocould be
# A security hole so don't ask .)
#
DIALER_SCRIPT =/etc/ppp/dialer.163 # dialing login script file name
#
# Initiate the connection
#
# I put most of the common options on this command. Please, don't
# Forget the 'lock' option or some programs such as mgetty will not
# Work. The asyncmap and escape will permit the PPP link to work
# A telnet or rlogin connection. You are welcome to make any changes
# As desired. Don't use the 'defaultroute 'option if you currently
# Have a default route to an ethernet gateway.
#
Exec/usr/sbin/pppd debug lock modem crtscts/dev/ttycua0 57600 \
Asyncmap 20A0000 escape FF kdebug 0 $ LOCAL_IP: $ REMOTE_IP \
Noipdefault netmask $ NETMASK defaultroute connect $ DIALER_SCRIPT
  
Then, check your login session program/etc/ppp/dialer.163. in my 163 ISP, the session program copied from the template can be used directly, you need to slightly modify this session program:
  
(1) If the prompt for entering the user name is not login:
(2) if the user needs to interact with each other and enter the command after successful logon, the ppp protocol will be started.
In Appendix 3, a modified logon script is added according to the preceding requirements.
Suggestion: If you have multiple ISP connections, create multiple dialing PPP connection scripts and corresponding PPP login scripts.
  
4. start or disconnect PPP
The only thing you need to do to start your PPP connection is to enable the Modem and run the ppp.163 just written. Your ppp.163 script will automatically dial, send logon information, and complete protocol authentication. when you see that the data transmission indicator on your Modem is no longer flashing and the connection status is maintained, the PPP connection is complete, you can run the following command:
  
Netstat-r
  
View the current route table. if the PPP protocol is successfully connected, the route table will have the default route to connect to your ISP. Your PPP has been configured successfully.
  
If it fails, check the ppp error log file in/etc/PPP.
  
To disconnect the PPP connection, run the ppp-off command.
  
V. DNS configuration
After the PPP connection is successful, if you want to use services such as WWW browser, Ftp, and Telnet, you must correctly configure DNS domain name resolution. Therefore, once the PPP connection is complete, add a line in/etc/resolv. conf:
  
Nameserver
  
Note that nameserver is followed by the IP address of your ISP's DNS server, and this line of description must be placed before other nameserver instructions. otherwise, your Linux system will not access your ISP's DNS server. Then you can use various Internet services.
  
6. Automatically configure DNS resolution
This section is not required for PPP configuration, but it provides some convenience for PPP usage.
  
Because your Linux is not always connected to the Internet, the resolv. conf is different when you do not connect to PPP. Therefore, we hope there is a way to automatically set the appropriate resolv. conf on Linux based on different situations.
  
In/etc/ppp, there are two scripts that run automatically based on the PPP connection status, ip-up and ip-down, which run when the PPP establishes a connection and disconnects, respectively, if you want to execute some commands during a PPP connection or disconnection, you can create a script file ip-up.local and a ip-up.local in the/etc/ppp directory and place the command to be executed in these two files. When PPP establishes a connection, ip-up calls the ip-up.local and executes the user command; when PPP is disconnected, ip-down calls the ip-down.local and executes the user command.
  
Therefore, we can use this mechanism to automatically configure DNS resolution as follows:
  
(1) edit the DNS resolution configuration files for the PPP connection status and the normal local status under/etc. we assume that the two files are resolv. ppp and resolv. normal.
  
(2) create a ip-up.local under/etc/ppp, set its execution permissions, and add: cp/etc/resolv. ppp/etc/resolv. conf to the file
  
(3) Create a ip-down.local under/etc/ppp, set its execution permissions, and add: cp/etc/resolv in the file. normal/etc/resolv. after conf is set in this way, every time the PPP connection is successful,/etc/resolv. the conf content is resolv. ppp, while/etc/resolv. conf is restored to resolv. normal content.
  
Appendix 1: PPP connection script template ppp-on
  
#! /Bin/sh
#
# Script to initiate a ppp connection. This is the first part of
# Pair of scripts. This is not a secure pair of scripts as the codes
# Are visible with the 'Ps' command. However, it is simple.
#
# These are the parameters. Change as needed.
TELEPHONE = 555-1212 # The telephone number for the connection
ACCOUNT = george # The account name for logon
PASSWORD = gracie # The password for this account
LOCAL_IP = 0.0.0.0 # Local IP address if known. Dynamic = 0.0.0.0
REMOTE_IP = 0.0.0.0 # Remote IP address if desired. Normally 0.0.0.0
NETMASK = 255.255.255.0 # The proper netmask if needed
#
# Export them so that they will be available at 'ppp-on-dialer' time.
Export TELEPHONE ACCOUNT PASSWORD
#
# This is the location of the script which dials the phone and logs
# In. Please use the absolute file name as the $ PATH variable is not
# Used on the con

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.