Fedora10 PPTPクライアント
14 12 月 2008
いろんなサイトで、PPTPサーバーの構築方法はあると思いますが、クライアント側がなかなかないので、構築した記録を書いときます。
1. まずVPN PPTPに必要なパッケージ、pptp-1.7.2-3.fc10.i386 をインストールする
※ 2008/12/14 現在
# yum -y install pptp
|
2. スクリプトファイルを作成する
PPTPクライアント用の設定ファイルを作成する ※ その都度接続する場合は # vi /usr/bin/pptp-client ※ 自動起動する場合は # vi /etc/rc.d/init.d/pptp-client ------------------------------ ここから ------------------------------ #!/bin/bash # # PPTP # chkconfig: - 99 20 # # description: PPTP service script # Source function library. . /etc/rc.d/init.d/functions SERVER="pptpサーバー" # 接続先の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 pptpd..." 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 5 if [ ! -z "$(/sbin/pidof pptp)" ]; then route add -net $HOSTNET netmask $HOSTMASK dev ppp0 echo -e " [\033[32m OK\033[0m ]" else echo -e " [\033[31m NG\033[0m ]" fi touch /var/lock/subsys/pptp else echo "pptpd allready running!!!" fi ;; stop) if [ -z "$(/sbin/pidof pptp)" ]; then echo "pptpd not running!!!" else echo -n "Shutting down pptpd..." /usr/bin/killall /usr/sbin/pptp if [ -f $RESOLVCONFBAK ] ;then cp -p $RESOLVCONFBAK $RESOLVCONF fi until [ -z "$(/sbin/pidof pptp)" ]; do :; done rm -f /var/lock/subsys/pptp echo -e " [\033[32m OK\033[0m ]" fi ;; status) if [ -z "$(/sbin/pidof pptp)" ]; then echo -e "pptpd not running...\n" else echo -e "pptpd is running... pid=[ \033[32m$(/sbin/pidof pptp)\033[0m ]\n" fi ;; version) echo -e "$(/usr/sbin/pptp --version)\n" ;; restart) $0 stop $0 start ;; *) echo -e "\nUsage: $0 {start|stop|restart|status|version}\n" exit 1 esac exit 0 ------------------------------ ここまで ------------------------------ PPTPクライアント用の設定ファイルに実行権を与える ※ その都度接続する場合は # chmod +x /usr/bin/pptp-client ※ 自動起動する場合は # chmod +x /etc/rc.d/init.d/pptp-client # chkconfig --add pptp-client # chkconfig pptp-client on # chkconfig --list pptp-client pptp-client 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
3. PPTP接続
※ その都度接続する場合 オプション無しで開始してみる # pptp-client Usage: /usr/bin/pptp-client {start|stop|restart|status|version} ↑ヘルプが出る。 開始してみる # pptp-client start Starting pptpd... [ OK ] # ←プロンプトが帰ってきたことを確認 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 status pptpd is running... pid=[ 3677 3662 ] # pptp-client version pptp version 1.7.2 切断してみる # pptp-client stop Shutting down pptpd... [ OK ] # ←プロンプトが帰ってきたことを確認 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 ↑ エラーが帰ってきていることの確認。 これで切断された状態になっている。 以上です。 |
Comments are closed.
