3. Surftime

3.1. PPPd Setup

Right, to start off you will need a working installation of PPPd, I know from experience that Mandrake 8.0 that sometime is doesn't install pppd so check its installed first. Once it is it usually resides in /usr/sbin/pppd check that any users you want to access it have setuid access.

Note: Setuid allows pppd to run as-if root allowing non-superusers to run pppd without less problems. To do this use the command chmod 4750 /usr/sbin/pppd. Beware: Some distributions have a watchdog program that will change the pppd permissions back to normal. I have not tested this but on RedHat derived systems with Linuxconf installed then removing the /usr/lib/linuxconf/redhat/perm/ppp should stop this happening.

3.2. Chatscript (Dialup)

The Chatscript is a text file, usually residing in /etc/ppp that contains the commands passed to the modem to make it dial to BTi. If you want to compare this to DUN in Windows then this is the phone number and init commands.

Below is the chatscript used to dial BTi, I've now opted for putting the \T metacharacter in the script. The means when we run chat, inside the pppd command, we can use a -T parameter and supply the needed telephone number.

  "" "ATZ"

  # The next two lines should be left commented out until
  # the script works.

  # "OK" "ATL0"
  # "OK" "ATM0"
  
  SAY "Dialing modem...\n"
  "OK" "ATDT \T"
  ABORT BUSY
  ABORT "NO CARRIER"
  TIMEOUT 60
  CONNECT \c

This script will dial BTi providing you put in the \T so we can added the telephone number later. I suggest saving the chatscript as something like /etc/ppp/chatscript Once you've saved it we can move onto setting up BTi's CHAP authentication.

3.3. Authentication

With PPP dialup's the most widely used authentication method, apparently, is PAP (Password Authentication Protocol). However, just to be a pain in the backside BTi use CHAP (Challenge Handshake Authentication Protocol). To be fair CHAP is a more secure authentication method than PAP but it's still a pain. Now PPPd does support this but not through nice easy to use Linuxconf dialogs.

In the /etc/ppp directory should be a chap-secrets that looks roughly like this when first installed:

  # Secrets for authentication using CHAP
  # client    server    secret    IP addresses

We can safely ignore the IP Address column but the others me must worry about. So fill in the gaps like this:

  # Secrets for authentication using CHAP
  # client    server    secret    IP addresses
  "bloggs@btinternet.com"  *   "mypasswordhere"

These two extra lines will try and authenticate ANY outgoing PPP connection that responds using CHAP using your BTi details. It goes without saying that you replace bloggs@btinternet.com and mypasswordhere with your details. Also, the second line is not strictly needed but I've found it helps sometimes.

Note: If you're not using BTi at this point you can usually get away with having identical chap-secrets and pap-secrets. If you the same kind of pattern as above it should work.

I suggest that you do a "chmod 600 /etc/ppp/*secrets". It was pointed out to me that it stops pppd shouting about security.

3.4. Setting your global options

In your /etc/ppp directory there is a file called options. If your open it with your favourite text editor you should see:

  lock

And thats it, now we need to add some more settings in here so make it look like:

  lock
  usepeerdns
  defaultroute
  noipdefault
  noauth
  asyncmap 0
  crtscts
  modem
  115200

Don't worry what they do, if you're interested look at the man page for pppd. As a passing note if you would like PPPd to redial dropped connections then add persist to the end of your options file.

3.5. Testing your link

Now you've created your Chatscript there are only two steps left till you should be on the Internet. First is getting a working link and second is creating a couple of easy dialup scripts to help you.

To test your link try this command:

pppd ttyS0 connect '/usr/sbin/chat -v -TPHONE_NUM_HERE -f /etc/ppp/chatscript' updetach debug name bloggs@btinternet.com

Now obviosuly if your testing at Daytiem rate add the Daytiem number where instead of PHONE_NUM_HERE and similar with Surftime.

This will tell PPPd to dial the modem on ttyS0 (COM1) using the chatscript. The updetach tells PPPd to only fork away to the commandline after the connection is established and the debug will show all authentication commands onscreen (providing updetach it set) while it trys to connect.

If that connected then move onto the next section and we can make a set of scripts to allow easy dialing.

3.6. Dialing scripts

Here I'll just set out a set of scripts that will let your dial BTi from a command line easily. The following should be self-explanatory, the italic filename is the filename to put the data into and the proceeding text the file contents:

/etc/ppp/peers/bt-surf

  ttyS0 connect '/usr/sbin/chat -v -TSURFTIME_NUMBER_HERE -f /etc/ppp/chatscript' 
  updetach name bloggs@btinternet.com

/etc/ppp/peers/bt-day

  ttyS0 connect '/usr/sbin/chat -v -TDAYTIME_NUMBER HERE -f /etc/ppp/chatscript' 
  updetach name bloggs@btinternet.com

Change any of the filenames to suit what you called them and the username. Do the same with this:

/usr/bin/internet

  #!/bin/bash
  # a script to dial BTi
  case "$1" in
  daytime)
     /usr/sbin/pppd call bt-day
     ;;
  surftime)
     /usr/sbin/pppd call bt-surf
     ;;
  off)
     killall pppd
     ;;
  esac

Once you've done that run this command at the command prompt:

chmod a+x /usr/bin/internet

Now you've done, simply type internet daytime/surftime/off and it will connect you to the internet.