FreeOS.com logo

FreeOS Most Popular
* Most Read stories
* Commented Stories
* Active Categories
* Non Linux Section
* User Submitters
* Top Polls
* Top Authors
* Top Reviews
* Top Rated
* Top Search Terms

Top Articles
* Writing a Linux device driver
* The Linux filesystem explained
* Samba NT Domain Controller
* Setting up Squid as your caching HTTP/FTP proxy
* Web server tutorial - Part 1

FreeOS Highlights
* Howtos (72)
* Reviews (20)
* Opinions (18)
* Interviews (8)
* News (3)

My FreeOS

Nick:
Pass:
Register

Forgot your password?

Contact Us
Contact Us

       

Project: Linux triangle Howtos triangle

Setting up PPP and KPPPD

By Vans Information <vcontent@vsnl.com>
Posted: ( 2001-07-09 03:40:12 EST by ramnath )

A tutorial on setting up and using PPP and KPPD

PPP (Point to Point Protocol) is used to connect the Red hat Linux system to the ISP through the modem. PPP is faster and more efficient. It uses the TCP/IP network protocol. SLIP(Serial Line Interface Protocol) is also used as the replacement but it is not as successful as PPP. Most of the ISP's prefer PPP.

Setting up PPP
In order to set up PPP, first a dummy interface has to be set up. When connected to an ISP, the IP address is assigned dynamically. It will be appropriate to assign a dummy IP address to our machine, which leads back to the same machine. It is assigned inside the file "/etc/hosts"
127.0.0.1 localhost localhost.localdomain.

This IP address 127.0.0.1 is always reserved for all the local machines in a network. After writing to the /etc/hosts file, the following commands has to be given by logging in as root.
Ifconfig lo 127.0.0.1
Route add 127.0.0.1
Where "lo" is the Localhost and "add" is the address. This determines the end past of the creating of dummy interface. The proper functioning of the dummy interface can be determined by the commands "ifconfig lo" and "ping localhost".

The two components used by PPP on your system are:
1. The demon called ppppd - Controls the use of PPP
2. The driver called High-level Data Link Control (HDLC) - Controls the flow of information between two machines.

When the Red Hat Linux is installed, PPP usually comes along with it. In case of its absence, we have to collect them from the Linux web sites, or else they have to be installed directly from the CD using the "rpm" command.

rpm -ivh /mnt/cdrom/Redhat/RMPS/ppp -2*rpm

As we are connecting our machine to the internet, we have to create a separate logging in order to prevent the hackers. By writing into the "/etc/passwd" file,
ppp:*.500:50:ppp account:/tmp:/etc/ppp/pppscript
a user called ppp with the login id 500 is created without a password.
Chat script tells the PPP about the details on the modem and how to use it. A chat script can be created by
"" ATZ OK ATDT5328835 CONNECT " " ogin: mylogin word: mypassword
Here the script contains 532-8835 as the phone number along with the login and password.

Then the chat handles the control over to pppd. It can be manually started by
pppd /dev/cua0 38400 crtscts defaultroute
where "/dev/cua0" is the serial port, 38400 is the speed, "crtscts" specifies hardware handshaking, " defaultroute" specifies local IP address.


KPPPD

Kppp is the front end for pppd and is a dialer. The dialling process in the ISP is automated by the kppp. It helps us to monitor the entire process. Kppp allows network set-up and interactive script generation. It will provide a set of statistics, which is useful to maintain all the activities in the modem. A script generator and a built in terminal provides easiness on setting up the connection. Kppp features elaborate phone cost accounting, which enables you to easily track you online costs. There is no need to set up any additional programs to set-up and monitor the system.
Kppp needs write permission to /etc/resolv.conf if you want to be able to take advantage of its capability to let you specify the DNS addresses in the DNS dialog.
Make sure that the pppd's option file which usually resides in /etc/ppp/ exists, but is empty. pppd requires it to exist, but it must be empty otherwise pppd will not take its options from kppp.

Steps for Installation of KPPPD
Make sure you are logged in as root, and then do the following:

Run kppp (either by clicking the K button at the bottom left of your screen, or running "kppp&" from the command prompt.

Click on the "Setup"

Click on the "New"

Type in a name for the connection (such as, "VSNL", "Satyam", etc.)

Type in the phone number. You may use character such as "-" to make the number more legible.

kppp will attempt to execute the command specified here once a ppp link has been set up. This will bring up the pppd arguments dialog. You may use this dialog to add any desired options that you want kppp to hand to pppd. Make sure that it always contains the -detach option. See the pppd man page for a list of available options. Unless you know exactly what you are doing you should restrain from tinkering with the pppd options.

Select the authentication type ("Script-based" for VSNL dial-up, "PAP" for Satyam or VSNL ISDN).

Enter any DNS data. Your present DNS setup on your Linux machine as configured. Specify the domain name for your machine. As with DNS Addresses it is restored to the original specified in „/etc/resolv.conf" when the connection goes down. If it is left blank no changes are made to the domain name specified in /etc/resolv.conf Add the Domain Name servers assigned to you by your ISP. You must specify at least a Domain Name server for your OS to be able to resolve human readable IP addresses such as ftp.kde.org. The DNS server addresses supplied must be in numeric form, e.g 128.231.231.233. The addresses will be added at runtime to „/etc/resolv.config".

If you are using PAP authentication then that's all you need to configure for the account. If your ISP just gave you a user id and a password for a PAP account the odds are that you can skip this section and that you will get by just reading the next one entitled 'PAP with kppp'.
PAP seems a lot more complicated at first glance than it really is. The server (the machine you are connecting to) basically tells the client (your machine) to authenticate using PAP. The client (pppd) looks in a specific file for an entry that contains a matching server name and client's name for this connection, and then sends the password it finds there. That's about it! Now, here's how to make that happen. We are assuming a pppd version of 2.2.0 and a standard installation of configuration files under /etc/ppp.
For the purposes of illustration, pretend that we have an Internet account with 'glob.net', under the user name 'booger', and a password of 'foobar'. First, we need to add all this to the file /etc/ppp/pap-secrets . The format of an entry for our purposes, is:
USERNAME SERVERNAME PASSWORD
so we add the line:
booger glob foobar
to the file and save it.

Note: We can use any name for the server we wish as long as we use the same name in the pppd arguments, as we'll see shortly. We have shortened it to 'glob'. This name is just used to locate the correct password.

Now, we need to set up our connection in kppp. The basics are the same as any other connection, and we won't go into details here, except to say that you probably want to make sure that the /etc/ppp/options, is empty, and you probably don't want any login script either. Now, in the settings dialog, at the bottom, is the pppd arguments button. This brings up a dialog similar to the one used for editing the login script. Here we enter values that will be sent to pppd as command line arguments, and in the case of multiple-value arguments, we need to enter each value as a separate entry in the listbox, in the correct order.

We can put any other arguments in here we want first. Usually you would want to hand kppp the default options '-detach' and 'defaultroute'. Now we need to add arguments that pppd needs to handle PAP authentication. In this example we are going to add 'user', 'booger', 'remotename', 'glob', in that order. The user argument tells pppd what user name to look for in pap-secrets, and send to the server. The remotename is only used by pppd to match the entry in the pap-secrets file, and is not sent to the server, so once again, it can be anything we want as long as it is consistent with the entry in the pap-secrets file.
That's all there is to it. You should now be able to set up your own connection to a server with PAP authentication. CHAP should not be much different. See the Linux Network Administrators' Guide for chap-secrets file format and pppd arguments used. The rest should be gravy, but...your mileage, ah you know the rest.

If you are using VSNL dialup (not ISDN) then you also have to define the login script-click on the tab "Login Script", and enter the script as:
Expect username:
ID
Expect password:
Password
Pause 1
Send ppp
Expect ~

Click on "Device" and set it up for your modem. The defaults should be good enough. (Remember that ttyS0 is COM1, and ttyS1 is COM2)

Modem Device: /dev/ttyS0
Flow Control: CRTSCTS
Line Termination: CR/LF
Connection Speed : 115200

Enable Lockfile and set the modem timeout to 30 or 60 seconds (30 is usually enough for tone dialing exchanges).

Click on "Modem".

Make sure that "Modem asserts CD line" is not enabled.

Set "Busy Wait" to the number of seconds you want to wait between attempts (probably 0)

One reason you might want to send the modem commands directly is if you have a set of modem configurations you want to keep, and not have to specify for every connection. A good way to do that is via modem profiles. Modems can have several stored profiles numbered 0,1,... AT&V can be used to view them all. The default profile is usually 0 (this can be changed via AT&Y.) The profile currently in use is called the "active" profile.
When you change a setting, the active profile is modified. The ATZ command will have the modem load the default profile, erasing any changes you have made. To save changes, Load the profile you want to change via ATZn (where n is the profile number). Make the changes you want, and then save it with AT&Wn. To have kppp use the profile you want, change the modem initialisation string (Settings/More/Modem/Modem Commands/Initialisation String.) For example ATZ1 will have the kppp reset the modem and use stored profile #1.
If you want reset you modem to get back to some known starting point, use AT&F&W to set the active profile to the factory defaults, and store those settings as the default profile.

Click on Modem Commands, and set your favorite initialization string: In most cases "AT&FX1L3S10=200" should be enough. If you have to dial Pulse instead of Tone, change the Dial String from ATDT to ATDP. Click on OK.

Now to see if your modem is talking to the serial port, click on Query modem, after a few seconds you should see some results, and should also see the send or receive lights on your modem flashing. If they don't (and if Data Terminal Ready-DTR dosen't come on) then you have selected the wrong modem port, correct that in the Device setting. If the lights flash but you still get an error message, your port speed in Device is probably too high, change it to 57600 or lower. When kppp opens the serial port, the DTR line is pulled low, on an external modem, you can see the DTR (or TR) light come on when this happens. When the TR light goes out (because kppp has closed the serial port, or something worse!), the modem will hang-up

Finally, click on the PPP tab, and enable all settings except "Quit on Disconnect". Set pppd timeout to 30 seconds. Click on OK. Repeat this entire sequence for any other dialup accounts you want to define. Create the file /etc/ppp/ip-up.local, and put the following commands.

#!/bin/sh

/usr/bin/killall -9 named

/usr/sbin/named/etc/named.conf.online

grep -v pppconnection /etc/hosts > /tmp/hosts.tmp

echo "$4 pppconnection" >> /tmp/hosts.tmp

mv /tmp/hosts.tmp /etc/hosts

ntpdate 128.175.1.3 &> /dev/null &

wall "Internet connection established ($4)"

echo 'date' CONNECT $4 >> /var/log/ppplog

Save the file. Create the file /etc/ppp/ip-down.local, and out the following commands :

#!/bin/sh
/usr/bin/killall -9 named
/usr/sbin/named /etc/named.conf
grep -v pppconnection /etc/hosts > /tmp/hosts.tmp
mv /tmp/hosts.tmp /etc/hosts
wall "Internet connection lost"
echo 'date' DISCONNECT >> /var/log/ppplog Save the file.

Make both files executable:
Chmod +x /etc/ppp/*.local

Copy the file "/etc/named.conf" to "/etc/named.conf.online". Then edit the file "/etc/named.conf" and remove the following 4 lines from it:

Zone "." {
Type hint;
File "named.ca";
};

Save the file.
Dialing out

Set "Connect to" to the account you want to dial, enable "Show Log Window", and hit the Connect button.

The System will now start dialing. You can watch the progress in the log window. Once you are connected, the Connection window will minimize in the right bottom corner. To disconnect, click on the modem icon and choose Disconnect.

Fire up Netscape if you haven't used K>utilities>Menu Editor to add Netscape to the menu, just open a terminal window and type "Netscape &".

There, this is the end. Now get ready for a practical ride on KPPPD in your own machine.

Other articles by Vans Information

Current Rating: [ 5.19 / 10 ] Number of Times Rated: [ 16 ]

More Howtos
* Kernel Compilation & Avoiding ‘Unresolved Symbol’
* Configuring CVS and CVSUP on Linux
* Knoppix installation tips
* Maximum Mount
* A WebServer Guide -- Help Using Apache

Contents
Articles
  Howtos
  Interviews
  News
  Opinions
  Reviews
Comparison
Links
  Articles
  Howtos
  Interviews
  Opinions
  Reviews
  Websites
News

Linux
About Linux

Print It!
Printer Friendly Version