Connecting to Netvision with a cable modem in Panther (Mac OS X 10.3)

I Recently updated to Mac OS 10.3 and found that the PPTP connection required by my ISP stopped working, giving the message:

PPTP received unexpected message type = 6699

The way it should works is for the mac to get an IP address via DHCP from the cable modem and then establish a "tunnel" to the ISP using PPTP.
Apple provides in its "Internet Connect" utility an option for establishing this kind of tunnel (using the "New VPN Connection..." menu). While this worked fine in "Jaguar" (Mac OS X 10.2) in Panther it would fail the authentication process (the method suggested by the ISP doesn't work. It didn't work for Jaguar either).

Luckily when I had still Jaguar I prepared a shell script to open the PPTP tunnel. I did this so that the scrip would run at boot time, before log-in. During the boot process the system tries to synchronize its clock with a time server, since the PPTP tunnel is needed to access the internet it would always fail. Not a big issue really but an annoyance.

Creating the script was actually quite easy. I connected to the ISP with the GUI and then in Terminal I issued the ps command to see which processes where running. ps needs the following options or modifiers for this:

  -a Display information about other users' processes as well as your own.
  -x Display information about processes without controlling terminals.
  -w Use 132 columns to display information. If specified more than once, ps will use as many columns as necessary regardless of the window size. (use -www )

The relevant process is pppd, the PPP daemon.
I simply copied that line and made a script with it:

In Panther I removed some arguments until it worked. The final script looks like this:

The script has to be given permissions to be executed (chmod a+x)

Although you have invoke the command from the terminal, the VPN dialer will reflect the state of the connection and will shows the connection log:

And if the "Internet Connect" application is running when the script is run, its dock icon will reflect the state:

You can get the script here.
Don't forget to enter your own username and password and verify that the PPTP server address is correct.


Updates
2004.05.12 I installed Panther on my second hard disk and when I tried to connect using the script it would get an IP address and would work with numeric addresses but apparently the DNS wasn't functioning (there was no resolv.conf file under /var/run). To fix this simply add the option usepeerdns to the script.
2004.05.25 I was made aware of this apple document that shows how to correct a related PPTP problem in Panther.
2004.05.27 Mac OS 10.3.4 fixes this problem. More here.


Running the script at boot time

This method works for Jaguar (Mac OS 10.2) only! I haven't updated it for 10.3 yet.

To make a script that runs during the boot process, create a folder in /Library/StartupItems called "pptp" or whatever you want to call your script.

You need two files here:

The first file should be called pptp and look like this"

#!/bin/sh
##
# PPTP to Netvision (13.02.04)
##
. /etc/rc.common
 StartService ()
 	  {
 ConsoleMessage "Starting PPTP connection"
 
 if [ -f /var/run/ppp0.pid ]; then
 echo "PPP already running"
 else
 pppd serviceid 32 logfile /tmp/ppp.log plugin PPTP.ppp remoteaddress 212.143.XXX.XXX redialcount 1 \
 redialtimer 5 mru 1500 mtu 1448 receive-all ipparam YYY.YYY.ZZZ.ZZZ defaultroute novj 0:0 noipdefault \
 ipcp-accept-local ipcp-accept-remote noauth user USERNAME password PASSWORD looplocal
 fi
 if ! [ -f /var/run/ppp0.pid ]; then
 echo "Warning: PPTP was not started"
 fi
 }
 StopService ()
 {
 if pid=$(GetPID pppd); then
 ConsoleMessage "Disconnecting PPTP"
 kill -TERM "${pid}"
 else
 echo "PPTP is not running."
 fi
 }
 RestartService ()
 {
 if pid=$(GetPID pppd); then
 ConsoleMessage "Restarting PPTP Connection"
 kill -HUP "${pid}"
 else
 StartService
 fi
 }
 RunService "$1"

Change the XXX for the IP address of the PPTP server, the YYY.YYY.ZZZ.ZZZ for the IP address for the cable modem and fill in your username and password.

This file has to be made executable.

Note that the pppd command is not preceded by sudo.

The second file is called StartupParameters.plist and should look like this:

{
  Description     = "PPTP to Netvision";
  Provides        = ("pptp");
  Requires        = ("NetworkExtensions");
  Uses            = ("IPServices", "Network");
  OrderPreference = "None";
}

More information on creating startup items can be found here.