FreeBSD ハンドブック : PPP と SLIP : カーネル PPP の設定 : PPP クライアントとしての動作
Previous: カーネル PPP の設定
Next: PPP サーバとしての動作

14.2.1. PPP クライアントとしての動作

私は, CISCO ターミナルサーバの PPP 回線に接続するために, 下記のような /etc/ppp/options を使用しています.

crtscts		# enable hardware flow control
modem		# modem control line
noipdefault	# remote PPP server must supply your IP address.
		# if the remote host doesn't send your IP during IPCP
		# negotiation , remove this option
passive		# wait for LCP packets
domain ppp.foo.com	# put your domain name here

:<remote_ip>	# put the IP of remote PPP host here
		# it will be used to route packets via PPP link
		# if you didn't specified the noipdefault option
		# change this line to <local_ip>:<remote_ip>

defaultroute	# put this if you want that PPP server will be your
		# default router

接続方法:

  1. kermit (またはその他のモデム操作プログラム) を使ってリモートホストに ダイヤルし, 接続してください. そして, あなたのユーザ名とパスワード (必要 であれば, その他にもリモートホストで PPP を有効にするための操作) を入力 します.
  2. kermit を抜けてください. (回線を切断せずに)
  3. 下記のように入力します:
    /usr/src/usr.sbin/pppd.new/pppd /dev/tty01 19200
    
    (通信速度とデバイス名には, あなたの環境に適したものを入れてください)

これでこのコンピュータは PPP で接続されました. もし, なんらかの理由で 接続に失敗したならば, /etc/ppp/options ファイルに "debug" オプションを追加して, 問題点を突き止めるために, コンソールに表示される メッセージを調べてください.

下記の /etc/ppp/pppup スクリプトは, 上記の作業を すべて自動的におこないます:

#!/bin/sh 
ps ax |grep pppd |grep -v grep
pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'`
if [ "X${pid}" != "X" ] ; then
        echo 'killing pppd, PID=' ${pid}
        kill ${pid}
fi
ps ax |grep kermit |grep -v grep
pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'`
if [ "X${pid}" != "X" ] ; then
        echo 'killing kermit, PID=' ${pid}
        kill -9 ${pid}
fi

ifconfig ppp0 down
ifconfig ppp0 delete

kermit -y /etc/ppp/kermit.dial
pppd /dev/tty01 19200

/etc/ppp/kermit.dial は kermit 用のスクリプトで, ダイヤルして, リモートホストでの認証に必要なすべての処理をおこないます. (そのようなスクリプトの例はこの文書の終わりに添付してあります)

PPP 接続を切断するには, 下記のような /etc/ppp/pppdown スクリプトを 使用します:

#!/bin/sh
pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'`
if [ X${pid} != "X" ] ; then
        echo 'killing pppd, PID=' ${pid}
        kill -TERM ${pid}
fi

ps ax |grep kermit |grep -v grep
pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'`
if [ "X${pid}" != "X" ] ; then
        echo 'killing kermit, PID=' ${pid}
        kill -9 ${pid}
fi

/sbin/ifconfig ppp0 down
/sbin/ifconfig ppp0 delete
kermit -y /etc/ppp/kermit.hup 
/etc/ppp/ppptest

PPP が動作中かどうかを調べます (/usr/etc/ppp/ppptest):

#!/bin/sh
pid=`ps ax| grep pppd |grep -v grep|awk '{print $1;}'`
if [ X${pid} != "X" ] ; then
        echo 'pppd running: PID=' ${pid-NONE}
else
        echo 'No pppd running.'
fi
set -x
netstat -n -I ppp0
ifconfig ppp0

モデム回線を切断します (/etc/ppp/kermit.hup):

set line /dev/tty01	; put your modem device here
set speed 19200
set file type binary
set file names literal
set win 8
set rec pack 1024
set send pack 1024
set block 3
set term bytesize 8
set command bytesize 8
set flow none

pau 1
out +++
inp 5 OK
out ATH0\13
echo \13
exit

次は kermit の代わりに chat を使う方法です.

原作: Robert Huff <rhuff@cybercom.net>.

pppd 接続を確立するためには, 次の二つのファイルの設定だけで十分です.

/etc/ppp/options:

 /dev/cuaa1 115200

crtscts		# enable hardware flow control
modem		# modem control line
connect "/usr/bin/chat -f /etc/ppp/login.chat.script"
noipdefault	# remote PPP server must supply your IP address.
		# if the remote host doesn't send your IP during
		# IPCP negotiation, remove this option
passive		# wait for LCP packets
domain <your.domain>	# put your domain name here

:		# put the IP of remote PPP host here
		# it will be used to route packets via PPP link
		# if you didn't specified the noipdefault option
		# change this line to <local_ip>:<remote_ip>

defaultroute	# put this if you want that PPP server will be
		# your default router

/etc/ppp/login.chat.script:

(実際には一行になります.)

ABORT BUSY ABORT 'NO CARRIER' "" AT OK ATDT<phone.number>
 CONNECT "" TIMEOUT 10 ogin:-\\r-ogin: <login-id>
 TIMEOUT 5 sword: <password>

正しくインストールし編集した後は, 必要な事はこれだけです

pppd.

このサンプルは主に Trev Roydhouse <Trev.Roydhouse@f401.n711.z3.fidonet.org> から寄せられた情報に基づいており, 承諾を得て使用しています.


FreeBSD ハンドブック : PPP と SLIP : カーネル PPP の設定 : PPP クライアントとしての動作
Previous: カーネル PPP の設定
Next: PPP サーバとしての動作