前提条件
Linuxに固有の準備
| alias char-major-10-200 tun |
|
mkdir /dev/net mknod /dev/net/tun c 10 200 |
| net.ipv4.ip_forward = 1 |
FreeBSDに固有の準備
| gateway_enable="YES" |
VPNの準備・インストール(各OS共通)
必要なものをそろえる。|
tar xvzf openssl*.gz cd openssl* ./config make su make install |
|
tar xvzf lzo*.gz cd lzo* ./configure make su make install |
|
tar xvzf vtun*.gz cd vtun ./configure --with-lzo-headers=/usr/local/include --with-lzo-lib=/usr/local/lib --sysconfdir=/etc/vpn --localstatedir=/var make su make install |
このソフトはクライアント/サーバ・スタイルを取っているので、設定ファイルの内容がクライアントとサーバで若干異なるので注意。
options {
ifconfig /sbin/ifconfig;
route /sbin/route;
}
# Default session options
default {
type tun;
proto tcp;
encr yes;
speed 0;
keepalive yes; # サーバ固有。接続を維持する。
compress lzo:9;
}
MyVPN { # MyVPNは、このVPN接続につける任意の名前
pass password; # passwordは、接続に必要なパスワード
up { # 接続時に実行する一連のコマンド群(ifconfig/route)
ifconfig "%% inet ccc.ccc.ccc.ccc qqq.qqq.qqq.qqq mtu 1450";
route "add -net ccc.ccc.ccc.0/24 qqq.qqq.qqq.qqq";
};
down { # 切断時に実行する一連のコマンド群(ifconfig/route)
route "delete ccc.ccc.ccc.0";
ifconfig "%% delete down";
};
}
|
options {
ifconfig /sbin/ifconfig;
route /sbin/route;
timeout 60;
}
# Default session options
default {
type tun;
proto tcp;
encr yes;
speed 0;
compress lzo:9;
persist yes; # クライアント固有。切断されたとき、自動的に再接続。
}
MyVPN { # MyVPNは、このVPN接続につける任意の名前
pass password; # passwordは、接続に必要なパスワード
up { # 接続時に実行する一連のコマンド群(ifconfig/route)
ifconfig "%% inet sss.sss.sss.sss rrr.rrr.rrr.rrr mtu 1450";
route "add -net sss.sss.sss.0/24 rrr.rrr.rrr.rrr";
};
down { # 切断時に実行する一連のコマンド群(ifconfig/route)
route "delete xxx.xxx.xxx.0";
ifconfig "%% delete down";
};
}
|
|
#!/bin/sh /usr/local/sbin/vtund [option] |
| -s | サーバモードで起動 |
| -i | inetdタイプのサーバモードで起動 |
| なし | クライアントモードで起動 |
| redirect_port (VPNルータのIPアドレス):5000 5000 |