Fedora9 PPTPクライアント
12 11 月 2008
いろんなサイトで、PPTPサーバーの構築方法はあると思いますが、クライアント側がなかなかないので、構築した記録を書いときます。
1. まずVPN PPTPに必要なパッケージ、pptp-1.7.1-4.fc9.i386、pptpconfig(GUI設定ツール)をインストールする
※ 2008/11/12 現在
# yum -y install pptp ここからはGUI用のパッケージです。 コマンド環境では必要ないと思います。 ので、その下の [ 2. スクリプトの作成 ] へ。 ※ 当サイトでは入れてしまいましたが。もし上だけで無理でしたら一応入れてみてください。 # yum -y install gtk+ # yum -y install libglade # wget http://pptpclient.sourceforge.net/yum/stable/fc9/i386/pptpconfig-20060821-1.fc9.noarch.rpm # wget http://pptpclient.sourceforge.net/yum/stable/fc9/i386/php4-pcntl-4.4.9-1.fc9.i386.rpm # wget http://pptpclient.sourceforge.net/yum/stable/fc9/i386/php4-pcntl-gtk-1.0.2-4.fc9.i386.rpm # rpm -ivh php4-pcntl-4.4.9-1.fc9.i386.rpm # rpm -ivh php4-pcntl-gtk-1.0.2-4.fc9.i386.rpm # rpm -ivh pptpconfig-20060821-1.fc9.noarch.rpm |
2. スクリプトファイルを作成する
PPTPクライアント用の設定ファイルを作成する # vi /usr/bin/pptp-client ------------------------------ ここから ------------------------------ #!/bin/sh SERVER="接続先サーバ" # 接続先のIPアドレス or ホスト名 USER="ユーザ名" # PPTP用 ユーザー名 PASSWORD="パスワード" # PPTP用 パスワード HOSTNET="192.168.0.0" # 接続先のネットワークアドレス HOSTMASK="255.255.255.0" # 接続先のネットマスク RESOLVCONF="/etc/resolv.conf" RESOLVCONFBAK="/tmp/resolv.conf.bak" DEBUG="debug" LOGLEVEL="2" case "$1" in start) if [ -z $(/sbin/pidof pptp) ]; then echo -n "Starting pptp-client" if [ -f $RESOLVCONF ] ;then cp -p $RESOLVCONF $RESOLVCONFBAK fi /usr/sbin/pppd \ $DEBUG lock noauth nodeflate nobsdcomp noccp \ name $USER \ password $PASSWORD \ require-mppe \ pty "/usr/sbin/pptp $SERVER --nolaunchpppd --loglevel $LOGLEVEL" sleep 10 route add -net $HOSTNET netmask $HOSTMASK dev ppp0 echo else echo "pptp-client is already started" fi ;; stop) if [ ! -z $(/sbin/pidof pptp) ]; then echo -n "Shutting down pptp-client" /usr/bin/killall pptp if [ -f $RESOLVCONFBAK ] ;then cp -p $RESOLVCONFBAK $RESOLVCONF fi echo else echo "pptp-client is not running" fi ;; restart) if [ ! -z $(/sbin/pidof pptp) ]; then echo -n "Shutting down pptp-client" /usr/bin/killall pptp if [ -f $RESOLVCONFBAK ] ;then cp -p $RESOLVCONFBAK $RESOLVCONF fi echo else echo "pptp-client is not running" fi if [ -z $(/sbin/pidof pptp) ]; then echo -n "Starting pptp-client" if [ -f $RESOLVCONF ] ;then cp -p $RESOLVCONF $RESOLVCONFBAK fi /usr/sbin/pppd \ $DEBUG lock noauth nodeflate nobsdcomp noccp \ name $USER \ password $PASSWORD \ require-mppe \ pty "/usr/sbin/pptp $SERVER --nolaunchpppd --loglevel $LOGLEVEL" sleep 10 route add -net $HOSTNET netmask $HOSTMASK dev ppp0 echo else echo "pptp-client is already started" fi ;; status) if [ ! -z $(/sbin/pidof pptp) ] ; then echo -n "pptp-client (pid" echo -n " `/sbin/pidof pptp`" echo ") is running..." else echo "pptp-client is stopped" fi ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac exit 0 ------------------------------ ここまで ------------------------------ PPTPクライアント用の設定ファイルに実行権を与える # chmod +x /usr/bin/pptp-client |
3. PPTP接続
オプション無しで開始してみる # pptp-client Usage: /usr/bin/pptp-client {start|stop|restart|status} ↑ヘルプが出る。 開始してみる # pptp-client start Starting pptp-client # ←プロンプトが帰ってきたことを確認 IPアドレスを確認する # ifconfig eth0 Link encap:Ethernet HWaddr 00:1E:90:D3:46:B1 inet addr:xxx.xxx.xxx.xxx Bcast:xxx.xxx.xxx.xxx Mask:255.255.255.0 inet6 addr: fe80::xxx:xxxx:xxxx:xxxx/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6271143 errors:0 dropped:0 overruns:0 frame:0 TX packets:6592528 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1963469937 (1.8 GiB) TX bytes:312092375 (297.6 MiB) Interrupt:20 Base address:0x8c00 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1251500 errors:0 dropped:0 overruns:0 frame:0 TX packets:1251500 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:181020084 (172.6 MiB) TX bytes:181020084 (172.6 MiB) 以下が追加されていることの確認 ppp0 Link encap:Point-to-Point Protocol inet addr:192.168.0.6 P-t-P:192.168.0.1 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 RX packets:6 errors:0 dropped:0 overruns:0 frame:0 TX packets:5 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:3 RX bytes:60 (60.0 b) TX bytes:56 (56.0 b) サーバー側のネットワーク内のPCにpingをとばしてみる # ping -c 4 192.168.0.80 PING 192.168.0.80 (192.168.0.80) 56(84) bytes of data. 64 bytes from 192.168.0.80: icmp_seq=1 ttl=254 time=6.56 ms 64 bytes from 192.168.0.80: icmp_seq=2 ttl=254 time=6.04 ms 64 bytes from 192.168.0.80: icmp_seq=3 ttl=254 time=6.16 ms 64 bytes from 192.168.0.80: icmp_seq=4 ttl=254 time=5.92 ms --- 192.168.0.80 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3009ms rtt min/avg/max/mdev = 5.926/6.175/6.562/0.238 ms ↑ エラーが帰ってきていないことの確認。 これでつながった状態になっている。 切断してみる # pptp-client stop Shutting down pptp-client # ←プロンプトが帰ってきたことを確認 IPアドレスを確認する # ifconfig eth0 Link encap:Ethernet HWaddr 00:1E:90:D3:46:B1 inet addr:xxx.xxx.xxx.xxx Bcast:xxx.xxx.xxx.xxx Mask:255.255.255.0 inet6 addr: fe80::xxx:xxxx:xxxx:xxxx/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:6271143 errors:0 dropped:0 overruns:0 frame:0 TX packets:6592528 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1963469937 (1.8 GiB) TX bytes:312092375 (297.6 MiB) Interrupt:20 Base address:0x8c00 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1251500 errors:0 dropped:0 overruns:0 frame:0 TX packets:1251500 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:181020084 (172.6 MiB) TX bytes:181020084 (172.6 MiB) ↑ ppp0 がなくなっている サーバー側のネットワーク内のPCにpingをとばしてみる # ping -c 4 192.168.0.80 PING 192.168.0.80 (192.168.0.80) 56(84) bytes of data. --- 192.168.0.80 ping statistics --- 4 packets transmitted, 0 received, 100% packet loss, time 12999ms ↑ エラーが帰ってきていることの確認。 これで切断された状態になっている。 以上です。 GUI環境の場合は、 # pptpconfig で、設定画面が現れるので ① Linux VPN v0.30 ② Fedora Core 4でYAMAHAルータにPPTPアクセス ↑ この辺を参考に |
Comments are closed.
