|Leased line Mini HOWTO|
You need a pppd (Point to Point Protocol Daemon) and a reasonable knowledge of how it works. Consult the relevant RFC's or the Linux PPP HOWTO if necessary. Since you are not going to use a login procedure, you don't use (m)getty and you do not need a (fake) user associated with the pppd controlling your link. You are not going to dial so you don't need any chat scripts either. In fact, the modem circuit and configuration you have just build, are rather like a fully wired null modem cable. This means you have to configure your pppd the same way as you would with a null modem cable.
For a reliable link, your setup should meet the following criteria;
Shortly after booting your system, pppd should raise the DTR signal in your RS232 port, wait for DCD to go up, and negotiate the link.
If the remote system is down, pppd should wait until it is up again.
If the link is up and then goes down, pppd should reset the modem (it does this by dropping and then raising DTR), and then try to reconnect.
If the quality of the link deteriorates too much, pppd should reset the modem and then reestablish the link.
If the process controlling the link, that is the pppd, dies, a watchdog should restart the pppd.
Suppose the modem is connected to COM2, the local IP address is `Loc_Ip' and the remote IP address is `Rem_Ip'. We want to use 576 as our MTU. The /etc/ppp/options.ttyS1 would now be:
crtscts mru 576 mtu 576 passive Loc_Ip:Rem_Ip -chap modem #noauth -pap persist #maxfail 0 #holdoff 10
crtscts mru 576 mtu 576 passive 192.168.1.1:10.1.1.1 -chap modem #noauth -pap persist #maxfail 0 #holdoff 10
crtscts mru 576 mtu 576 passive 10.1.1.1:192.168.1.1 -chap modem #noauth -pap persist #maxfail 0 #holdoff 10
You could start the pppd form a boot (rc) script. However, if you do this, and the pppd dies, you are without a link. A more stable solution, is to start the pppd from /etc/inittab;
s1:23:respawn:/usr/sbin/pppd /dev/ttyS1 115200
Note: Some older systems will not accept the speed `115200'. In this case you will have to set the speed to 38400 and set the `spd_vhi' flag with setserial. Some systems expect you to use a `cua' instead of `ttyS' device.
The default route can be set with the defaultroute option or with the /etc/ppp/ip-up script;
#!/bin/bash case $2 in /dev/ttyS1) /sbin/route add -net 0.0.0.0 gw Rem_Ip netmask 0.0.0.0 ;; esac
Of course the route set in ip-up is not necessarily the default route. Your ip-up sets the route to the remote network while the ip-up script on the remote system sets the route to your network. If your network is 192.168.1.0 and your ppp interface 192.168.1.1, the ip-up script on the remote machine looks like this;
#!/bin/bash case $2 in /dev/ttyS1) /sbin/route add -net 192.168.1.0 gw 192.168.1.1 netmask 255.255.255.0 ;; esac
Some systems use dynamic ttys, in which case you can't route on a tty basis. In this case it might be handy to translate the ip address to a ppp interface and then do the routing (and firewalling) on a ppp interface basis. For this purpose I edited /etc/ppp/ip-up;
# These variables are for the use of the scripts run by run-parts PPP_IFACE="$1" PPP_TTY="$2" PPP_SPEED="$3" PPP_LOCAL="$4" PPP_REMOTE="$5" PPP_IPPARAM="$6" export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM # translate ip to ppp echo $PPP_IFACE > "/var/run/ppp/if-$PPP_LOCAL" sleep 1 # Rerun firewall. /usr/local/sbin/rc.block # Take care of the (default) route(s) case $PPP_LOCAL in "My_Ip_Address") /sbin/route add -net 0.0.0.0 gw $PPP_REMOTE netmask 0.0.0.0 ;; esac # Fix things missed at boot if ! ( netstat -an | grep 'My_Ip_Address:53' > /dev/null 2>&1 ) then # Just booted # Sync clock /usr/local/sbin/ntpdate.sh & # Set the null routes /usr/local/sbin/null-route.sh & # Bind 9 needs this; sleep 1 /etc/init.d/bind9 restart fi # An audiable notification /bin/echo -ne "\007" >> /dev/tty1
#!/bin/bash route add -net 10.0.0.0 netmask 255.0.0.0 reject route add -net 172.16.0.0 netmask 255.240.0.0 reject route add -net 192.168.0.0 netmask 255.255.0.0 reject
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 255.255.255.255 0.0.0.0 255.255.255.255 UH 0 0 0 eth1 220.127.116.11 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0 10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 192.168.0.0 - 255.255.0.0 ! 0 - 0 - 172.16.0.0 - 255.240.0.0 ! 0 - 0 - 10.0.0.0 - 255.0.0.0 ! 0 - 0 - 0.0.0.0 18.104.22.168 0.0.0.0 UG 0 0 0 ppp0
Test the whole thing just like the modem test. If it works, get on your bike and bring the remote modem to the remote side of your link. If it doesn't work, one of the things you should check is the COM port speed; Apparently, a common mistake is to configure the modems with Minicom using one speed and then configure the pppd to use an other. This will NOT work! You have to use the same speed all of the time!