Connecting to the Internet through PPP

Prerequisite

We'll use Red Hat 6.1 and a V.34 modem in this example. Make sure the modem works hardware-wise. Under DOS, you can type "ECHO ATDT > COM1" and "ECHO ATH > COM1" to test that the modem is set up correctly, without using a terminal application (replace COM1 with the ad hoc communication port, if applicable.)

Next, check that there is a symbolic link to /dev/modem (COM1 = /dev/ttyS0, COM2 = /dev/ttyS1, etc.) Use terminal program Minicom to check that you can connect to your ISP manually in ASCII mode.

PPP is a two-part thing: It has to be compiled in the kernel (in the kernel itself, or be available as loadable module: The kernel installed by RH during the initial install had PPP available as a module, as it should be since you're only using PPP when connected to your ISP, so it's a waste of memory to have PPP compiled in the kernel itself), and you must have PPPd installed (if it was installed through RPM, which is likely, run rpm -qa | grep ppp .)
 

To connect through a script

Name the two following scripts ppp-on and ppp-off, respectively, make them executable (chmod +x ppp-on), move them to /usr/sbin, and check that /usr/sbin is part of your PATH so you can run them using relative path (echo $PATH to check)
 
#!/bin/sh
# ----------------ppp-on
rm -f /var/spool/uucp/LCK* /var/lock/LCK* /var/run/ppp*.pid
pppd /dev/modem connect 'chat -v -f /root/.pppscript' defaultroute 115200 &
#!/bin/sh
#----------------ppp-off
if [ "$1" = "" ]; then
DEVICE=ppp0
else
DEVICE=$1
fi
if [ -r /var/run/$DEVICE.pid ]; then
kill -INT `cat /var/run/$DEVICE.pid`
if [ ! "$?" = "0" ]; then
rm -f /var/run/$DEVICE.pid
echo "ERROR: Removed stale pid file"
exit 1
fi
rm -f /var/spool/uucp/LCK* /var/lock/LCK*
echo "PPP link to $DEVICE terminated..."
echo
/usr/sbin/connect
echo
exit 0
fi
echo "ERROR: PPP link is not active on $DEVICE"
exit 1


Add the following configuration file to /root, and name it .pppscript

REPORT CONNECT
ABORT 'ERROR'
ABORT 'BUSY'
ABORT 'NO CARRIER'
ABORT 'NO DIALTONE'
'' ATZ OK AT&FE1V1&C1&D2S95=47+MS=11,1,300,33600 OK ATDT0155400040 CONNECT ''
ogin: yourloginhere
ssword: yourpasswordhere


Update /etc/pap-secrets (if your ISP uses PAP as authentication method, otherwise /etc/chap-secrets). The two *'s are very important. I don't know if it's OK to use TAB's instead of spaces.

# Secrets for authentication using PAP
# client  server secret  IP addresses
mylogin  *  mypassword  *


Add the following to /etc/resolv.conf

domain myisp.com
nameserver <first DNS server IP address here>
nameserver <second DNS, if available>

To connect through KPPP

If you run KDE as your desktop, you can use the utility KPPP to create a connection profile, just like DUN under Windows. By default, PAP mode in KPPP expects the remote peer to also authenticate itself, so you get a "The remote system is required to authenticate itself but I couldn't find any suitable secret (password) for it to use to do so." Add noauth as argument to this connection profile.
 

Troubleshooting

If you get "can't locate module char-major-108" in /var/log/messages, it's just a warning due to new features being introduced in PPP which require your running an experimental kernel, ie. it shows up because RH installs stable kernels. To avoid this warning, add the following to /etc/conf.modules:
alias char-major-108 ppp


If you get "The remote system is required to authenticate itself but I couldn't find any secret (password) which would let it use an IP address.", make sure that you have the two *'s in /etc/ppp/pap-secrets .

If you connect in PPP alright, but get a "No PAP secret found" and the modem hangs up, add noauth by itself in /etc/ppp/options .

Using KPPP, if you cannot ping a host on the Internet through its IP address (Destination host unreachable), check that the default route ("gateway") is not set to another host, which should be the case if your computer is part of a LAN (in which case, you shouldn't need to set up a modem in your host to reach the Internet :-) To find out, run route -n and check if any line has 0.0.0.0 as its first column. If that's the case, run route del default to remove this, and let the ppp interface become the default gateway automagically when you connect to the Internet.
The reason for this, is that ppp does not replace the default route with itself if a default gateway already exists. Removing the default gateway and re-running pppd redirects all outside packets to the ppp interface.
 

Resources

Besides the PPP-HOWTO, also check out the excellent " How to hook up PPP in Linux" by W.G. Unruh available at http://axion.physics.ubc.ca/ppp-linux.html .