LoginSignup
7
7

More than 5 years have passed since last update.

Linuxサーバから自宅のネットワークにVPN接続をする

Posted at

環境

  • YAMAHA NVR500
  • Ubuntu 14.04

手順

sudo apt-get install pptp-linux
sudo pptpsetup --create <Profile> --server <IP> --username <PPTP Account> --password <Password> --encrypt
sudo pppd call <Profile> updetach

Profileには任意の接続名を指定します。
IPには、NVR500のグローバルIPを指定します。YAMAHAの場合、DDNSサービスを使って、xxxxxx.aa0.netvolante.jpというホスト名を指定するのがいいでしょう。
PPTP Account/Passwordは、NVR500側で設定したものを指定します。

ifconfigでppp0が表示されていれば接続が成功しています。
一旦、切断を行います。

sudo poff <Profile>

接続手順の簡略化

必要な時だけVPN接続をするので、接続手順を楽にするためにスクリプト化しておく。

  • Profileはvpn
  • 自宅のネットワークは、192.168.1.0/24
vpn-connect.sh
#!/bin/bash
pon vpn

sleep 5

route add -net 192.168.1.0 netmask 255.255.255.0 ppp0
vpn-disconnect.sh
#!/bin/bash
poff vpn

接続

sudo vpn-connect.sh

切断

sudo vpn-disconnect.sh
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7