Using the PPP-on script in Linux for GPRS dial-up Internet access

Source: Internet
Author: User
In Linux, dialing is based on the PPP protocol, which is consistent with that in windows.
In Windows, the dial-up program is used to encapsulate the protocol on a graphical interface. Therefore, it is hard to detect the Protocol during dial-up.
In Linux, pppd is used, so it is clearer than windows.
In Linux, the GUI dialing program is kppp, which encapsulates pppd.

In Linux, the scripts used for dialing are PPP-on, PPP-on-dialer, and PPP-off.
You can find these three scripts under/usr/share/doc/PPP/script under the default rh9 installation.

These three scripts were originally used to make a dial-up script for a common Modem,
We can use these three scripts to make certain changes to achieve PPP dial-up GPRS internet access.

Dialing principle:
The initialization module mainly sets the APN: cmnet
At + cgdcont = 1, ip, cmnet
Then use the chat program to dial * 99 *** 1 #
After the dial-up connection is successful, pppd will establish a communication link.

The script is changed as follows:
In PPP-on, the phone number is changed to * 99 *** 1 #
Clear accounts and passwords,
Changed the dialer_script path.
Change the following device to/dev/ttys0 and the speed to 19200.
Remove the crtscts parameter,
  
Remove the account password from PPP-on-dialer.

The changed script is as follows:
#! /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 = * 99 *** 1 # the telephone number for the connection
Account = # the account name for Logon (as in 'George Burns ')
Password = # The password for this account (and 'gracie Allen ')
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 connect option. (to do so on a 'root' account wocould be
# A security hole so don't ask .)
#
Dialer_script =/home/testboot/PPP-on-dialer # path for storing 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
# 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 nocrtscts modem/dev/ttys0 19200/
Asyncmap 20a0000 escape FF kdebug 0 $ local_ip: $ remote_ip/
Noipdefault netmask $ netmask defaultroute connect $ dialer_script

After the modification is complete, run the script PPP-on.
./PPP-on
Dial-up Internet access

If you want to write a program to execute this script, you can use the exec function. For the specific usage of exec, see the C function manual.
One thing to note is that when exec is used, the original process will be annihilated, and only the executed program is running. Therefore, if you want to keep the original process, I use the fork function to execute scripts in sub-processes, and execute my own programs in the parent process.

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.