外部から自宅にアクセスできるように
LinuxマシンをPPPサーバーに仕立てる


(着信監視にmgetty+sendfaxを使う)


 サーバー側マシンでモデムの着信を検出する方法としてmgettyを使った場合のサーバーとクライアントの設定です。

 Linux環境は,サーバークライアントとも Slackware3.1(ppp 2.2.0f) + mgetty+sendfax 1.0.0 + kernel 2.0.30 です。またモデムはどちらもttyS1(com2)に接続してしてあるものとしています。サーバークライアントともPPPのカーネルドライバを組み込んでおきます。
 mgetty+sendfaxはFAXモデムを使ったFAXの送受信の機能を持っていますが,ここではPPPの自動起動の機能を使います。

サーバーの設定

  1. mgetty+sendfaxのコンパイルとインストール
     mgetty+sendfax-1_0_0_tar.gz をインターネットサイトなどから入手し,ソースファイルを展開します。
     policy.h-distをpolicy.hにコピーし,policy.hを修正変更します。注意する箇所は次の所です。
    #define DEVICE_GROUP		"modem"  (/etc/groupにmodemグループを作成しておきます)
    #define DEFAULT_PORTSPEED	115200
    #define MODEM_INIT_STRING	"ATZ"
    

    次にMakefileを1ヶ所修正します。
    	CFLAGS=-O2 -Wall -pipe -DAUTO_PPP
    

    メーク,インストールして終了です。
    	make
    	make testdisk
    	make install
    

  2. /etc/inittabの設定を変更
    # Serial lines
    #s1:12345:respawn:/sbin/agetty 19200 ttyS0 vt100
    #s2:12345:respawn:/sbin/agetty 19200 ttyS1 vt100
    s2:345:respawn:/usr/local/sbin/mgetty -D -x2 /dev/ttyS1  
    

  3. /usr/local/etc/mgetty+sendfax/login.configを変更
    # SAMPLES:
    # Use this one with my Taylor-UUCP and Taylor-UUCP passwd files. 
    #  (Big advantage: tuucp can use the same passwd file for serial dial-in 
    #   and tcp dial-in [uucico running as in.uucpd]). Works from 1.05 up.
    #
    #U*     uucp    @       /usr/lib/uucp/uucico -l -u @
    #
    # Use this one for fido calls (login name /FIDO/ is handled specially)
    #
    # You need Eugene Crosser's "ifmail" package for this to work.
    #  mgetty has to be compiled with "-DFIDO", otherwise a fido call won't
    #  be detected.
    #
    #/FIDO/ uucp    fido    /usr/local/lib/fnet/ifcico @
    #
    # Automatic PPP startup on receipt of LCP configure request.
    #  mgetty has to be compiled with "-DAUTO_PPP" for this to work.
    #  Warning: Case is significant, AUTOPPP or autoppp won't work!
    #  Consult the "pppd" man page to find pppd options that work for you.
    #
    /AutoPPP/ -  -   /usr/sbin/pppd auth +pap login debug modem crtscts lock 192.168.1.100:192.168.1.101
     クライアントにPAP認証に答えるように強制します。認証ファイルは/etc/passwdを使用します。
    #
    #
    # An example where no login name in the argument list is desired:
    #  automatically telnetting to machine "smarty" for a given login name
    #
    #telnet-smarty  gast    telnet  /usr/bin/telnet -8 smarty
    #
    # This is the "standard" behaviour - *dont* set a userid or utmp
    #  entry here, otherwise /bin/login will fail!
    #  This entry isn't really necessary: if it's missing, the built-in
    #  default will do exactly this.
    #
    *  -   -   /bin/login @
    

  4. /etc/passwdにpppユーザーを登録
    ppp:password:uid:gid:ppp client:/tmp:/etc/ppp/ppp-server     
    
     パスワード,ユーザーID,グループIDはマシン環境に合わせて適切に設定してください。ホームディレクトリは/tmp,ログインシェルは/etc/ppp/ppp-serverとします。

  5. /etc/ppp/ppp-server(ユーザーpppのログインシェル)の作成
    #!/bin/sh
    #
    #      login shell for ppp user
    #
    LOCAL_IP=192.168.1.100		<---このIPアドレスはマシン環境に合わせて
    REMOTE_IP=192.168.1.101		    変更してください
    
    exec /usr/sbin/pppd passive debug modem lock crtscts $LOCAL_IP:$REMOTE_IP   
    
     このファイルには実行属性を設定しておきます。


     サーバー側の設定は以上です。
     シリアルポートが38400bpsの指定の時に115200bpsの速度で動作するようにsetserialコマンドを入力します。
      setserial  /dev/ttyS1  spd_vhi

     initを起動し直し,mgettyを起動します。
      init  q

     mgettyがシリアルポートに繋がったモデムの着信の監視を始めます。mgettyはアクセスがあると"login:"プロンプトを送信します。 ここでクライアント側からpppパケットを受信すると,login.configの/AutoPPP/で指定されたオプションでpppdを起動します。 pppdはPAP認証を行い認証に成功すると以降PPPでの通信が始まります。
     サーバー側に/etc/ppp/pap-secretsファイルが存在するとPAP認証が失敗します。この場合には,/etc/ppp/pap-secretsファイルにも認証用のID,パスワードを記述しておくとうまくいくようです。
    	# Secrets for authentication using PAP
    	# client server secret [IP address]
    	ppp       *  password        <---- /etc/passwdの設定に同じ
    
     受信したデータがpppパケットでない場合には"login"プロンプトに続くログインプロセスを実行します。 アクセスしたユーザーがpppのユーザー名でログインに成功すると/etc/ppp/ppp-serverが起動され,以降PPPでの通信が可能となります。


クライアントの設定

 PAP認証で接続するように設定します。
  1. /usr/sbin/ppp-onの設定を変更
    TELEPHONE=078-XXX-XXXX	<--- サーバー側の電話番号
    ACCOUNT=ppp		<--- ユーザー名は ppp とする
    LOCAL_IP=0.0.0.0
    REMOTE_IP=0.0.0.0
    NETMASK=255.255.255.0
    export TELEPHONE ACCOUNT
    DIALER_SCRIPT=/etc/ppp/ppp-on-dialer
    exec /usr/sbin/pppd debug lock modem crtscts /dev/ttyS1 38400 \
    	asyncmap 0 $LOCAL_IP:$REMOTE_IP \
    	noipdefault netmask $NETMASK defaultroute connect $DIALER_SCRIPT \
    	name $ACCOUNT
    

  2. /etc/ppp/ppp-on-dialerを次のとおり設定
    #!/bin/sh
    exec chat -v				\
    	TIMEOUT		3		\
    	ABORT		'\nBUSY\r'	\
    	ABORT		'\nNO ANSWER\r' \
    	ABORT		'\nRING\r\n\r\nRING\r' \
    	''		\\rATZ		\
    	'OK-+++\c-OK'	ATH0		\
    	TIMEOUT		60		\
    	OK		ATDT$TELEPHONE	\    <-- パルスダイヤルならATDP  
    	CONNECT		''
    

  3. /etc/ppp/pap-secretsの設定
    # Secrets for authentication using PAP
    # client server secret [IP address]
    ppp       *  password     <---- サーバー側の/etc/passwdの設定に同じ
    


     クライアント側の設定は以上です。
     シリアルポートが38400bpsの指定の時に115200bpsの速度で動作するようにsetserialコマンドを入力します。
      setserial  /dev/ttyS1  spd_vhi

     次にppp-onを起動します。
      tail -f /var/log/messages; ppp-on

     PPP接続を切断する場合にはppp-offコマンドを入力します。

     ここではPAP認証によるアクセス方法を示しましたが,サーバー側でuugettyが動作している場合のアクセス設定でも接続することは可能です。


Windows95でアクセス

 上で示したpppサーバーにはWindows95のダイヤルアップネットワークの機能を使って接続することができます。
 設定上特に注意するような点はありません。



戻る