How to use Linux dial-up Internet access

Source: Internet
Author: User
Tags nameserver


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. 2. Preparation of kernel your Linux system must be configured in kernel to support the PPP function. 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. I used a script to configure the PPP dial-up network. At first I 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) The directory where the dialup program is located for Redhat 5.0, these dialup programs (scripts) are under/usr/doc/ppp-2.2.0f/scripts, if you want to use these scripts, copy them to the correct directory as follows: PPP-on: PPP connection script copy to/usr/sbin PPP-off: PPP disconnect script copy to/usr/sbin PPP-on-dialer: PPP login session script copy to/etc/PPP-redialer: you can copy the login scripts of multiple phone numbers to/usr/sbin (this document is not required). 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. If 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, make sure that PPP-off is also executable (3) to customize your own dialing program, first edit your ppp.163, most of which do not need to be changed, as long as you modify the following: telephone = 163 account = Password = dialer_script =/etc/PPP/dialer.163 In addition, in the last line of exec starting pppd, note that the serial device file of your modem is provided (usually COM1/dev/cua0 or/dev/ttys0, com2/dev/cua1 or/dev/ttys1 ), and set the serial port communication speed (the default is 38400, for the current high-speed mod Em, this speed is too low, and can be set to more than 57600 ). The ppp.163 content after completion is :#! /Bin/sh # script to initiate a PPP connection. this is the first part of the # 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 # Username Password = yourpassword # password. Be sure to restrict others from reading this file! Local_ip = 0.0.0.0 # local IP address, 0.0.0.0 indicates Dynamic Allocation of 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 =/E TC/PPP/dialer.163 # Name of the dialing logon script file # 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 with # a telnet or rlogin connection. you are welcome to make any changes # as desired. don t use the defaultroute option if you currently # Ha Ve a default route to an Ethernet gateway. # exec/usr/sbin/pppd debug lock modem crtscts/dev/ttycua0 57600 \ asyncmap restart escape FF kdebug 0 $ local_ip: $ remote_ip \ noipdefault netmask $ netmask defaultroute connect $ 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 is successfully logged on, in this document, Appendix 3 is 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 PPP and disconnect PPP. The only thing you need to do to start your PPP connection is to enable 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, run the following command: netstat-R to check 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. 5. If you want to use the WWW browser, FTP, telnet, and other services after the DNS is configured with a successful PPP connection, you must correctly configure DNS domain name resolution. Therefore, once the PPP connection is complete. add a line to the conf file: nameserver, note that the 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. automatic DNS resolution is not required in this section, but it provides some convenience for the use of PPP. 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. The method is as follows: (1) edit the DNS resolution configuration file in/etc for the PPP connection status and normal local status respectively, 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 in the file. PPP/etc/resolv. conf (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 the # 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 AC Count 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 n Ame 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-on-dialer # 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 w Ith # 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/ttys0 38400 \ asyncmap 20a0000 escape FF kdebug 0 $ local_ip: $ remote_ip \ noipdefault netmask $ netmask defaultroute connect $ dialer_script Appendix 2: PPP logon Script Template PPP-on-Dia Ler #! /Bin/sh # This is part 2 of the PPP-on script. it will perform the connection # protocol for the desired connection. # exec chat-V \ timeout 3 \ abort \ nbusy \ r \ abort \ Nno answer \ r \ abort \ nringing \ r \ n \ r \ nringing \ r \ rat \ OK -+++ \ c-OK ATH0 \ timeout 30 \ OK atdt $ telephone \ connect \ ogin: -- ogin: $ account \ assword: $ password Appendix 3: a slightly modified PPP login script #! /Bin/sh # This is part 2 of the PPP-on script. it will perform the connection # protocol for the desired connection. # exec chat-V \ timeout 3 \ abort \ nbusy \ r \ abort \ Nno answer \ r \ abort \ nringing \ r \ n \ r \ nringing \ r \ rat \ OK -+++ \ c-OK ATH0 \ timeout 30 \ OK atdt $ telephone \ connect \ sername: -- sername: $ account \ assword: $ password \ nnex: PPP Description: (1) the user logon prompt is changed from login: To Username: (2) after the user logs on, the user accesses the service Prompt Annex:, You need to manually enter the PPP command Appendix 4: PPP connection Script Template PPP-redialer #! /Bin/sh #################################### ################################# these parameters control the attack dialing sequence. # maximum number of attempts to reach the telephone number (s) max_attempts = 10 # delay between each of the attempts. this is a parameter to sleep # So use "15 s" for 15 seconds, "1 m" for 1 minute, etc. sleep_delay = 15 s #################################### ############# ################### This is a list of telephone numbers. add new numbers if you wish # And see the function callall below for the dial process. phone1 = 555-1212 phone2 = 411 ################################ ##################################### if you use the PPP-on script, then these are passed to this routine # automatically. there is no need to define them here. if not, then # You will need Set the values. # account = my_account_name Password = my_password ################################# #################################### function to initialize modem and ensure that it is in command # state. this may not be needed, but It doesn t hurt. # function initialize {chat-V timeout 3 at OK-++ \ c-OK return }################### ######################################## ######### script To dial a telephone # function callnumber {chat-V \ abort \ nbusy \ r \ abort \ Nno answer \ r \ abort \ nringing \ r \ n \ r \ nringing \ r \ atdt $1 \ connect \ ogin: -- ogin: $ account \ assword: $ password # If the connection was successful then end the whole script with a # success. # If ["$? "=" 0 "]; then exit 0 fi return }################################## ################################### script to dial any telephone number # function callall {# echo "Dialing attempt number: $1 ">/dev/console callnumber $ phone1 # callnumber $ phone2 }######################## ######################################## ##### initialize the modem to ensure that it is in the Command state # initiali Ze if [! "$? "=" 0 "]; then Exit 1 fi # dial telephone numbers until one answers # attempt = 0 while :; do attempt = 'expr $ attempt + 1' callall $ attempt if ["$ attempt" = "$ max_attempts"]; then Exit 1 fi sleep "$ sleep_delay" done Appendix 5: PPP disconnection script PPP-off #! /Bin/sh #################################### #################################### determine the device be terminated. # If ["$1" = ""]; then device = ppp0 else device = $1 fi ############################## ######################################## # If the ppp0 PID file is present then the program is running. stop it. if [-r/var/run/$ device. PID]; then kill-int 'cat/var/run/$ device. PID '# I F The kill did not work then there is no process running for this # PID. it may also mean that the lock file will be left. you may wish # To delete the lock file at the same time. if [! "$? "=" 0 "]; then Rm-F/var/run/$ device. PID echo "error: removed stale PID file" Exit 1 fi # success. let pppd clean up its own junk. echo "PPP link to $ device terminated. "Exit 0 fi # the PPP process is not running for ppp0 echo" error: PPP link is not active on $ device "Exit 1
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.