Thursday, December 18, 2008

PPP

Documents to read:
1. Manual of pppd
2. PPP-HOWTO

Square brackets are used to separate keywords, such as filenames,
programs names etc etc from lines of text. They have no other meaning.

The Point-to-Point Protocol (PPP) provides a method for transmitting
datagrams over serial point-to-point links.


A possible PPP link between two hosts is shown below.

________ _________ _________ ________
| | | | | | | |
| Host-A |-ttyN-| modem-A |..............| modem-B |-ttyN-| Host-B |
|________| |_________| |_________| |________|
| |
ethN ethN
| |
A - network B - network

Figure-1

The above figure shows how computer network can be established between
two hosts with a modem at each end, using PPP. This figure also shows
that a PPP link can be used to connect two distant computer networks.
The main disadvantage is the speed of the link which is limited by the
speed of the modems.

Create directory [ppp] in your home directory.
$ mkdir $HOME/ppp

Carry out this experiment in that directory
$ cd $HOME/ppp

Bring
[ppp-681.txt] and
ppp_2.4.1.uus-4_i386.deb

in that directory. The actual package version number or name might
differ.

List the PPP related packages installed in your host.
$ dpkg -l | grep ppp

Replace the existing [pppd] or install [pppd].

# dpkg -i ppp_2.4.1.uus-4_i386.deb


From Figure-1 it is observed that a modem is to be connected to each
host. As a result, many modems are needed for one laboratory class. If
that many modems are not available, a simple PPP link over a short
distance can be established, using null modem ( cross-over cable )
between two hosts.


The following arrangement is to be used in this laboratory experiment.
______________________ ________________________
| | | |
| RxD Receive Data | 2 <--------- 3 | TxD Transmit Data |
| TxD Transmit Data | 3 ---------> 2 | RxD Receive Data |
| GND Signal Ground | 5 ---------- 5 | GND Signal Ground |
|______________________| |________________________|
| null-modem
| Host-1 Host-2
|
LAN

Figure-2

Host-1 is connected to laboratory LAN. Host-2 is kept disconnected
from the laboratory LAN. When PPP link is established between Host-1
and Host-2, Host-2 should be able to access other hosts of the LAN.
Hosts of the LAN should be able to access Host-2.


Figure-2 is redrawn to show the IP addresses associated with different
interfaces. Complete the addresses with pencil.

________ ________
| | 10.0.0.1(ppp0) 172.16.1.____(ppp0)| |
| Host-1 |------------------- null-modem -------------------| Host-2 |
|________| |________|
|172.16.1.____(eth0)
|
|
LAN ( 172.16.1.0 )

Figure-3


Record the IP address of eth0 interface of Host-2.

Host-2 # ifconfig

IP address of eth0 interface of Host-2---> ____________________

Use this address as the IP address of [ppp0] interface of Host-2. Use
pencil to write the address in Figure-3. We can use this address for
[ ppp0 ] interface, as eth0 interface of Host-2 is to be disabled in
this experiment.

Write the IP address of eth0 interface of Host-1 in Figure-3, using
pencil.

The eth0 interface of Host-2 is disabled
Host-2 # ifconfig eth0 down

Verify the effect of above command
Host-2 # ifconfig

The output should show loopback interface only. Host-2 is now
effectively disconnected from LAN. If Host-2 is rebooted, the command

# ifconfig eth0 down

must be executed again, for this experiment.

[ /etc/ppp/options ] is the configuration file for PPP daemon. PPP
daemon (pppd) is to be run on both Host-1 and Host-2.

The configuration file of [pppd] for Host-1 is shown below. The local-
IP-address of the PPP link is 10.0.0.1 . The far end of the PPP link
would supply the peer-IP-address, during the establishment of the PPP
link. It is assumed that null modem is using serial port [ttyS0].

-------- /etc/ppp/options --------
# configuration file for Host-1

/dev/ttyS0
57600
lock
debug
mru 296
# local-IP-address:peer-IP-address
10.0.0.1:
netmask 255.255.255.255
local # null modem is used
proxyarp
passive
----------------------------------


The configuration file of [pppd] for Host-2 is shown below. Write the
missing fourth octet of the local-IP-address of the PPP link. The far
end of the PPP link would supply the peer-IP-address, during the
establishment of the PPP link. In this experiment the peer-IP-address
would be 10.0.0.1 . It is assumed that null modem is using serial port
[ttyS0].

-------- /etc/ppp/options --------
# configuration file for Host-2

/dev/ttyS0
57600
lock
debug
mru 296
# local-IP-address:peer-IP-address
172.16.1.____:
netmask 255.255.255.255
local
----------------------------------


Find out the location of [pppd] binary executable file
Host-1/Host-2 # whereis -b pppd

location ------->


Check if [pppd] can access the options. Use full path-name if needed.

Host-1/Host-2 # pppd dryrun

Were the options printed ? ( Y / n )


If you are on Host-1, start [pppd].
Host-1 # pppd

In another terminal verify that [pppd] is running
$ ps ax | grep pppd


If you are on Host-2, start [pppd], while [pppd] is running in Host-1.
Host-2 # pppd


Use the following command and examine output
Host-1/Host-2 # tail -f /var/log/messages

Record the following:

Local IP address of PPP interface -------->
Remote IP address of the PPP interface --->


Try to access other hosts from Host-2. Use FTP, TELNET, PING etc etc.
Record the successful commands:









Try to access Host-2 from other hosts. Record the successful commands:









---------------------------

Optional Assignment:
In the above experiment, the commands were run
manually in the two hosts. The process may be automated if the
commands can be executed, at the later part of boot process. A shell
which runs the command, is executed, when a host boots.

Prepare the shell script.
Host-1/Host-2 $ nano $HOME/ppp/start-pppd

------------------- start-pppd -----------------------
#!/bin/bash

declare i x

while : # endless loop
do
x=$( /bin/pidof pppd )
if test -z $x # if value of x is a null string
then
echo "my-pppd: starting pppd"
/usr/sbin/pppd
elif test $x -gt 0 # PID value > zero
then
echo "my-pppd: pppd is running. PID = $x "
echo "my-pppd: sleeping for 5 minutes"
sleep 300
fi
done
# done > /tmp/myppd-debug

exit 0
------------------------------------------------------

The shell script starts [pppd], if [pppd] is not running. If [ pppd ]
is found running, it is checked at intervals of 5 minutes. The output
of the script would appears in Terminal-1. The reason for this is
explained later. This makes Terminal-1 unusable. The [ echo ] commands
may be commented, after the program is found to be working properly.
The output may also be redirected to a file, using the following
redirection in the script.

done > /tmp/myppd-debug


Make the file executable
Host-1/Host-2 $ chmod 0500 $HOME/ppp/start-pppd


Another shell script is prepared in [/etc/init.d] directory.
Host-1/Host-2 # nano /etc/init.d/my-pppd

------------ /etc/init.d/my-pppd --------------
#!/bin/bash

if test -x /home/your-login-name/ppp/start-pppd
then
/home/your-login-name/ppp/start-pppd &
fi

exit 0
-----------------------------------------------

Use actual path for the executable shell script [ start-pppd ]. The
above shell script checks the presence of the executable shell script
[ start-pppd ], in the specified path. If the test is successful, the
program [start-pppd] is started in background. Then [ my-pppd ] exits.
You must not omit the [&].


Make this program executable.

Host-1/Host-2 # chmod 0500 /etc/init.d/my-pppd

Create links to start the script in runlevels 2,3,4 and 5 (multiuser).
The following command may not be available in other Linux releases.

Host-1/Host-2 # update-rc.d my-pppd defaults

A possible output is shown:

Adding system startup for /etc/init.d/my-pppd ...
/etc/rc0.d/K20my-pppd -> ../init.d/my-pppd
/etc/rc1.d/K20my-pppd -> ../init.d/my-pppd
/etc/rc6.d/K20my-pppd -> ../init.d/my-pppd
/etc/rc2.d/S20my-pppd -> ../init.d/my-pppd
/etc/rc3.d/S20my-pppd -> ../init.d/my-pppd
/etc/rc4.d/S20my-pppd -> ../init.d/my-pppd
/etc/rc5.d/S20my-pppd -> ../init.d/my-pppd


At the end of the experiment, the links must be removed
Host-1/Host-2 # update-rc.d -f my-pppd remove



Reboot the two hosts in any order and check for establishment of PPP
link.

Did the PPP link come up ? ( Y / N )

If the PPP link does not come up, record the errors.

Errors:





---------------------

Note: PPP is widely used protocol. Most of dial-up computer networks
use this protocol. Many leased line computer networks use PPPoE
protocol. Many important aspects of PPP were skipped in this
experiment due to shortage of available time.