<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>VPN | 徒然なるままに</title>
	<atom:link href="https://www.seichan.org/tag/vpn/feed" rel="self" type="application/rss+xml" />
	<link>https://www.seichan.org</link>
	<description>徒然と日々の出来事(ネタ)を書いていこうかと．主に FreeBSD，Unix系の話題が中心ですが，その他の話題もあつかってみたり．</description>
	<lastBuildDate>Sat, 23 Mar 2024 02:48:33 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>
	<item>
		<title>FreeBSD で vtun を使って VPN 構築する方法</title>
		<link>https://www.seichan.org/2024/01/freebsd-%e3%81%a7-vtun-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6-vpn-%e3%82%92%e5%bc%b5%e3%82%8b.html</link>
					<comments>https://www.seichan.org/2024/01/freebsd-%e3%81%a7-vtun-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6-vpn-%e3%82%92%e5%bc%b5%e3%82%8b.html#respond</comments>
		
		<dc:creator><![CDATA[seichan]]></dc:creator>
		<pubDate>Sat, 20 Jan 2024 13:00:00 +0000</pubDate>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[VPN]]></category>
		<guid isPermaLink="false">https://www.seichan.org/blog/?p=2052</guid>

					<description><![CDATA[vtun というソフトウェアを利用した VPN を構成してみます．元々ブログ外で書いていたのですが説明を端折っていたのでブログで書き直します． vtun は「Virtual Tunnel」の略称でその名のとおり，IP ネ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">vtun というソフトウェアを利用した VPN を構成してみます．元々ブログ外で書いていたのですが説明を端折っていたのでブログで書き直します．</p>



<p class="wp-block-paragraph"><a rel="noopener" href="https://vtun.sourceforge.net/" target="_blank">vtun</a> は「<strong>Virtual Tunnel</strong>」の略称でその名のとおり，IP ネットワークでトンネルを張る為のプログラムです．オープンソースで公開されており，FreeBSD に限らず Linux でも利用が可能です．</p>



<p class="wp-block-paragraph">暗号化，圧縮，帯域制御など最低限の機能は持っています．</p>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">vtun を導入する</a></li><li><a href="#toc2" tabindex="0">vtun を構成する (サーバー側)</a><ol><li><a href="#toc3" tabindex="0">options ブロック</a></li><li><a href="#toc4" tabindex="0">default ブロック</a></li><li><a href="#toc5" tabindex="0">プロファイル ブロック (なんて呼べばいいのだろう)</a></li><li><a href="#toc6" tabindex="0">サービスの起動</a></li></ol></li><li><a href="#toc7" tabindex="0">vtun を構成する (クライアント側)</a><ol><li><a href="#toc8" tabindex="0">サービスの起動</a></li></ol></li><li><a href="#toc9" tabindex="0">接続を確認する</a><ol><li><a href="#toc10" tabindex="0">サーバー側およびクライアント側</a></li><li><a href="#toc11" tabindex="0">ping などでの確認</a></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">vtun を導入する</span></h2>



<figure data-wp-context="{&quot;imageId&quot;:&quot;6ab8fb4f086e0&quot;}" data-wp-interactive="core/image" data-wp-key="6ab8fb4f086e0" class="wp-block-image aligncenter size-full is-resized wp-lightbox-container"><img fetchpriority="high" decoding="async" width="830" height="472" data-wp-class--hide="state.isContentHidden" data-wp-class--show="state.isContentVisible" data-wp-init="callbacks.setButtonStyles" data-wp-on--click="actions.showLightbox" data-wp-on--load="callbacks.setButtonStyles" data-wp-on--pointerdown="actions.preloadImage" data-wp-on--pointerenter="actions.preloadImageWithDelay" data-wp-on--pointerleave="actions.cancelPreload" data-wp-on-window--resize="callbacks.setButtonStyles" src="https://www.seichan.org/blog/wp-content/uploads/2024/01/image-33.png" alt="" class="wp-image-2046" style="width:600px" srcset="https://www.seichan.org/blog/wp-content/uploads/2024/01/image-33.png 830w, https://www.seichan.org/blog/wp-content/uploads/2024/01/image-33-300x171.png 300w, https://www.seichan.org/blog/wp-content/uploads/2024/01/image-33-546x310.png 546w, https://www.seichan.org/blog/wp-content/uploads/2024/01/image-33-768x437.png 768w, https://www.seichan.org/blog/wp-content/uploads/2024/01/image-33-120x68.png 120w, https://www.seichan.org/blog/wp-content/uploads/2024/01/image-33-160x90.png 160w" sizes="(max-width: 830px) 100vw, 830px" /><button
			class="lightbox-trigger"
			type="button"
			aria-haspopup="dialog"
			data-wp-bind--aria-label="state.thisImage.triggerButtonAriaLabel"
			data-wp-init="callbacks.initTriggerButton"
			data-wp-on--click="actions.showLightbox"
			data-wp-style--right="state.thisImage.buttonRight"
			data-wp-style--top="state.thisImage.buttonTop"
		>
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
				<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
			</svg>
		</button></figure>



<p class="wp-block-paragraph">このようなネットワークの VPN を構成してみたいと思います．<br>以下，サーバーと書いているのは左側，クライアントと書いてあるのは右側を指します．</p>



<p class="wp-block-paragraph"><br>FreeBSD ではパッケージとして簡単に導入することが可能です．サーバー，クライアントとも <strong><em>pkg install vtun</em></strong> でパッケージを導入してください．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># pkg install vtun
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 2 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        lzo2: 2.10_1
        vtun: 3.0.4_8

Number of packages to be installed: 2

Proceed with this action? [y/N]: y
[1/2] Installing lzo2-2.10_1...
[1/2] Extracting lzo2-2.10_1: 100%
[2/2] Installing vtun-3.0.4_8...
[2/2] Extracting vtun-3.0.4_8: 100%
#</pre>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>



<h2 class="wp-block-heading"><span id="toc2">vtun を構成する (サーバー側)</span></h2>



<p class="wp-block-paragraph">設定ファイルは <strong>/usr/local/etc/vtund.conf</strong> になります．パッケージを入れた直後の設定ファイルは解説込みでとても長いのでまっさらな状態から作成したほうが良いです．</p>



<p class="wp-block-paragraph">サーバー側の設定ファイルはこのようになります．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># cat /usr/local/etc/vtund.conf

options {
  port        5000;
  bindaddr    { iface vmx0; };
  syslog      daemon;
  ifconfig    /sbin/ifconfig;
  route       /sbin/route;
}

default {
  type        tun;
  proto       tcp;
  persist     yes;
  keepalive   yes;
  compress    lzo:1;
  encrypt     yes;
  stat        yes;
  speed       0;
}

tokyo-osaka {
  password  P@ssw0rd!;
  device    tun0;
  up {
    ifconfig "%% 172.16.255.1/32 172.16.255.2 mtu 1440";
    route "add -net 192.168.2.0/24 172.16.255.2";
  };
  down {
    ifconfig "%% delete down";
    route "delete -net 192.168.2.0/24";
  };
}</pre>



<h3 class="wp-block-heading"><span id="toc3">options ブロック</span></h3>



<ul class="wp-block-list">
<li>port<br>サーバーで待ち受けるポート番号です．今回の例だと 5000 番で待ち受けます</li>



<li>bindaddr<br>どのアドレスで待ち受けるかを指定できます．今回は iface vmx0 と vmx0 インターフェイスを利用するよう指定をしています</li>



<li>syslog<br>syslog のファシリティを指定します</li>



<li>ifconfig<br>ifconfig コマンドのパスを指定します</li>



<li>route<br>route コマンドのパスを指定します</li>
</ul>



<p class="wp-block-paragraph">ifconfig / route のみ今回利用していますが，同様に ppp や firewall というオプションがあり，それぞれパスを指定できるようになっています．</p>



<h3 class="wp-block-heading"><span id="toc4">default ブロック</span></h3>



<p class="wp-block-paragraph">デフォルト値として定義するものを纏めるブロックになります．</p>



<ul class="wp-block-list">
<li>type tun<br>tun は tunnel デバイスを利用する宣言になります．そのほかに ether，tty，pipe を指定することができますが，ほぼ tun の利用になるかと思います．</li>



<li>proto tcp<br>トンネルを張る際に利用するプロトコルを指定します．tcp または udp を指定可能です．パフォーマンスの観点だと udp が良いです．クライアント側が IPoE を利用している場合 udp は利用ができないため tcp を指定しています．<br>PPPoE 環境の場合は udp の指定が可能です．</li>



<li>persist yes<br>セッションを張りなおすかの設定です．本来はクライアント側の設定になります．セッションが切れた場合再度接続を行うのかを yes または no で指定します．</li>



<li>keepalive yes<br>セッションを維持するかの設定です．サーバー側の設定になります．yes，no もしくは数字を入れます．yes の場合は 30:4 という指定と同義になり，30 秒毎にキープアライブのパケットを送信します．4回試行して成功しない場合は切断されます．</li>



<li>compress lzo:1<br>コネクションの圧縮を行うかを指定できます．yes，no の他，zlib と lzo が指定可能です．<br>zlib は tcp のみ利用可能です．zlib，lzo とも圧縮率を指定できます lzo:1 が圧縮率が低いけど CPU 負荷が低い，lzo:6 が圧縮率は高いけど CPU 負荷も高い．という形です．</li>



<li>encrypt yes<br>暗号を行うのかを yes，no で指定できます．</li>



<li>stat yes<br>yes の場合，5分毎にステータスログを出力します．</li>



<li>speed 0<br>帯域制限を行う場合は 0 以外の値を入れることができます． 単位は Kbit/sec です．</li>
</ul>



<h3 class="wp-block-heading"><span id="toc5">プロファイル ブロック (なんて呼べばいいのだろう)</span></h3>



<ul class="wp-block-list">
<li>tokyo-osaka<br>接続プロファイルの名称です．</li>



<li>password<br>VPN セッションを張る際の共通パスワードです．</li>



<li>device tun0<br>このセッションで利用するトンネルデバイスを指定します．</li>



<li>up<br>インターフェイスが UP した際 (接続された際) 記載したコマンドが実行されます．<br>今回は ifconfig でアドレス設定と route コマンドでの静的ルートの追加を行います．</li>



<li>down<br>インターフェイスが DOWN した際 (切断された際) 記載したコマンドが実行されます．<br>今回は作成されたインターフェイスの削除とルートの削除を行います．</li>
</ul>



<h3 class="wp-block-heading"><span id="toc6">サービスの起動</span></h3>



<p class="wp-block-paragraph">設定ファイルの準備ができたらサービスを起動させます．<br><strong>/etc/rc.conf</strong> に次の行を追加します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">vtund_enable="YES"
vtund_flags="-s"</pre>



<p class="wp-block-paragraph">続いて，次のコマンドを実行してサービスを起動させます．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># /usr/local/etc/rc.d/vtund start
Starting vtund.

# ps -ax | grep vtun
1569  -  Ss     0:00.00 vtund: waiting for connections on port 5000 (vtund)</pre>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>



<h2 class="wp-block-heading"><span id="toc7">vtun を構成する (クライアント側)</span></h2>



<p class="wp-block-paragraph">続いてクライアント側の設定ファイルです．サーバー側とほぼ変わらず，最後のセクションで実行するコマンドが違っています．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">options {
  port        5000;
  bindaddr    { iface vmx0; };

  syslog      daemon;

  ifconfig    /sbin/ifconfig;
  route       /sbin/route;
}

default {
  type        tun;
  proto       tcp;
  persist     yes;
  keepalive   yes;
  compress    lzo:1;
  encrypt     yes;
  stat        yes;
  speed       0;
}

tokyo-osaka {
  password  P@ssw0rd!;
  device    tun0;
  up {
    ifconfig "%% 172.16.255.2/32 172.16.255.1 mtu 1440";
    route "add -net 192.168.1.0/24 172.16.255.2";
  };
  down {
    ifconfig "%% delete down";
    route "delete -net 192.168.1.0/24";
  };
}</pre>



<h3 class="wp-block-heading"><span id="toc8">サービスの起動</span></h3>



<p class="wp-block-paragraph">クライアント側の設定ファイルの作成が終わったらサービスの起動を行います．<br><strong>/etc/rc.conf</strong> に次の行を追加します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">vtunclient_enable="YES"
vtunclient_list="site1"
vtunclient_site1_flags="tokyo-osaka 192.168.250.253"
vtunclient_site1_pidfile="/var/run/vtun-site1.pid"</pre>



<p class="wp-block-paragraph">vtunclient_list は複数のセッションを張る場合 <strong>&#8220;site1 site2&#8221;</strong> とスペース区切りで記載することができます．<br><strong>vtunclient_&lt;区切り名&gt;_flags</strong> というように次に続いていきます．<br>vtunclient_site1_flags は接続時に利用するプロファイルおよび vtun サーバーのアドレスを記載します．</p>



<p class="wp-block-paragraph">/etc/rc.conf の準備が終わったらサービスを起動します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># /usr/local/etc/rc.d/vtunclient start
Starting vtunclient.

# ps -ax | grep vtun
1976  -  S&lt;s    0:00.00 vtund: tokyo-osaka tun tun0 (vtund)</pre>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>



<h2 class="wp-block-heading"><span id="toc9">接続を確認する</span></h2>



<p class="wp-block-paragraph">両方のサービスの起動が完了したら接続状況を確認します．</p>



<h3 class="wp-block-heading"><span id="toc10">サーバー側およびクライアント側</span></h3>



<p class="wp-block-paragraph">tunX デバイスが生成されていること，IP アドレスが設定されていることを確認します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># ifconfig tun0
tun0: flags=8051&lt;UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1440
        options=80000&lt;LINKSTATE>
        inet 172.16.255.1 --> 172.16.255.2 netmask 0xffffffff
        groups: tun
        nd6 options=29&lt;PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        Opened by PID 1579</pre>



<p class="wp-block-paragraph">また，スタティックルートが追加されていることを確認します．</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            192.168.250.254    UGS        vmx0
127.0.0.1          link#4             UH          lo0
172.16.255.1       link#5             UHS         lo0
172.16.255.2       link#5             UH         tun0
192.168.1.0/24     link#2             U          vmx1
192.168.1.254      link#2             UHS         lo0
192.168.2.0/24     172.16.255.2       UGS        tun0
192.168.250.0/24   link#1             U          vmx0
192.168.250.253    link#1             UHS         lo0</pre>



<h3 class="wp-block-heading"><span id="toc11">ping などでの確認</span></h3>



<p class="wp-block-paragraph">ping などを利用してお互いに通信が出来るかを確認しましょう</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># ping 172.16.255.2
PING 172.16.255.2 (172.16.255.2): 56 data bytes
64 bytes from 172.16.255.2: icmp_seq=0 ttl=64 time=0.622 ms
64 bytes from 172.16.255.2: icmp_seq=1 ttl=64 time=0.539 ms
^C
--- 172.16.255.2 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.539/0.581/0.622/0.041 ms

# ping 192.168.2.254
PING 192.168.2.254 (192.168.2.254): 56 data bytes
64 bytes from 192.168.2.254: icmp_seq=0 ttl=64 time=0.454 ms
64 bytes from 192.168.2.254: icmp_seq=1 ttl=64 time=0.491 ms
^C
--- 192.168.2.254 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.454/0.473/0.491/0.018 ms</pre>



<p class="wp-block-paragraph">いかがでしょうか．vtun は難しい設定が無く割と簡単に VPN が構成できます．ただし，共有鍵であることと暗号強度は高くないのでガチの VPN を行いたい場合は別のソフトウェアを選定したほうが良いかもしれません．<br>自分は VPS と家を繋ぎたい目的だけなので vtun で十分と思って利用しています．用途・要件に応じて選択していけばよいと思います．</p>


<div class=".for-sp">
<div class="table">
<span class="body">
<!-- imobile wiki_上部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846007"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_上部_SP_1 -->
</span>
<span class="body">
<!-- imobile wiki_下部_SP_1 -->
<script type="text/javascript">
 imobile_tag_ver = "0.3"; 
 imobile_pid = "81546"; 
 imobile_asid = "1846017"; 
 imobile_type = "inline";
</script>
<script type="text/javascript" src="https://spad.i-mobile.co.jp/script/adssp.js?20110215"></script>
<!-- imobile wiki_下部_SP_1 -->
</span>
</div>
</div>

<div class=".for-pc">
<div class="table">
<span class="body">
<!-- imobile blog_seichan_記事中_1 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1846028"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_1 -->
</span>
<span class="body">
<!-- imobile blog_seichan_記事中_2 -->
<script type="text/javascript">
 imobile_pid = "81546"; 
 imobile_asid = "1845876"; 
 imobile_width = 300; 
 imobile_height = 250;
</script>
<script type="text/javascript" src="https://spdeliver.i-mobile.co.jp/script/ads.js?20101001"></script>
<!-- imobile blog_seichan_記事中_2 -->
</span>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.seichan.org/2024/01/freebsd-%e3%81%a7-vtun-%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6-vpn-%e3%82%92%e5%bc%b5%e3%82%8b.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
