Mac PPP server

From ShawnReevesWiki
Jump to navigationJump to search

In order to provide internet service to the modem of our old TiVo, I made an applescript that ran a shell script to forward its internet connection to a serial port.

Shawn's procedure

Use a null-modem connection.
  • Connect the serial port of the TiVo (or any computer) to a null-modem cable to a Keyspan 19HS USB to serial adapter.
  • On the host Mac, go to System Preferences and turn on internet sharing, through any unused port, not messing with existing connections like airport or ethernet. For example, share the internet connection from the Airport to the firewire port.
  • Execute the following in a shell, or a shell script (currently "~/pppdtivoscript").

and my applescript application "pppdTiVoScriptApplescript"

su
pppd noauth proxyarp /dev/cu.USA19H181P1.1 115200 172.16.1.4:172.16.1.18 passive local maxfail 0 nocrtscts xonxoff
explanation
  • 'noauth' since TiVo can't authenticate
  • 'proxyarp' to let system know TiVo is on network through computer
  • '/dev/cu.etcetera' to let pppd know which serial device
  • '115200' for serial speed. let's see how fast TiVo can go. Use dialing prefix ,#296 to tell TiVo to use serial (#2xx), 96 stands for 9600. Should be able to go up to ,#211 for 115200 baud. I have made a successful connection at 115200 with ,#211.
  • '172.16.1.4:172.16.1.18' to assign a computer and Tivo. The host IP address will change; it can be extracted from the system with the command LocalHostIP=`ifconfig | grep 'inet 172' | awk '{ print $2 }'`. Then we can use the variable $LocalHostIP before the colon. If we are not on a 172.16.1 network, we need to change that 172 to whatever net we're on.
  • 'passive' to wait for request from TiVo
  • 'local' to avoid using modem commands
  • 'maxfail 0' to keep trying
  • 'nocrtscts' not using control pins on serial cable, just ground, transmit, and receive, since serial port on TiVo is just 3 wires.
  • 'xonxoff' to use software flow control instead of hardware flow control, since serial port on TiVo has no control wires.
Addtional options for pppd
  • 'dump' to show what commands pppd is accepting

Our serial cable is a null modem cable, so connect 5-5, 3-3, 2-2 between it and the 1/8"-to-serial adapter. If you don't have a null modem cable, you can connect 5-5, 3-2, and 2-3. 5 is the signal ground, 2 is for receiving data, 3 is for transmitting data.

Apple Script

Pulling all together into an Apple Script app:

set pppdTivoScript to "LocalHostIP=`ifconfig | grep 'inet 172' | awk '{ print $2 }'`; KeyspanPort=`ls /dev | grep USA | grep cu`; echo \"Sharing ip connection from $LocalHostIP via pppd\"; /usr/sbin/pppd dump noauth proxyarp /dev/$KeyspanPort 115200 $LocalHostIP:172.16.1.38 passive local maxfail 0 nocrtscts xonxoff"
set scriptresult to do shell script pppdTivoScript with administrator privileges
display dialog "Output of pppdTiVoScript:" & return & scriptresult

Still to do

  • Generalize the apple script or shell script to find out what the router's address-range is and use that instead of assuming it's 172.etc.
    • Split pppdTivoScript into parts and parse the scriptresults in Apple Script, giving the user feedback along the way.
  • OR leave out the local address, PPPD will take the first address of the computer which is usually right.
  • Make sure the IP address assigned to the serial port is unique but still in the router's range. It might not be possible to find out which addresses are taken.
    • Only grep the "en[0-9]:" lines and the 5 that follow them (use option "-A 5"), since you could have all sorts of other IP addresses for loopback and virtual systems (like Parallels Desktop). Then grep the inet lines from that.:
ifconfig | grep -A 5 "en[0-9]:" | grep -o "inet .* netmask .* broadcast .*"
    • The assigned ip address should be much higher than inet, fit in netmask, and be lower than broadcast. This could be dangerous in a large network where you don't know all the clients, so only do this at home or if you know the upper limits of the clients' addresses.
  • OR use an IP address in the private network range so that there won't be any possible interference, unless we unfortunately choose the same private network range that's currently being served to the host by the network it's on.

References

Connecting two modems via ppp, as in Tivo to Mac

For reference, here are detailed instructions on how to do this with a PC:http://home.elp.rr.com/terlouw/DCWinMEServer.htm Also:http://www.tivohelp.com/archive/tivohelp.swiki.net/45.html

On a mac:http://www.linuxquestions.org/questions/showthread.php?t=131653

To execute shell scripts in Applescript
http://developer.apple.com/technotes/tn2002/tn2065.html
A similar method to share a network connection through bluetooth
http://blog.interlinked.org/mobile/bt_sharing.html

Using a System 7 Mac as a ppp-over-serial client. http://retromaccast.ning.com/forum/topics/1672786:Topic:31192