Ubuntuを使用したDMVPNのインストールと設定例

説明

DMVPN(Dynamic Multipoint VPN)は、すべてのデバイスを静的に設定する必要なく、複数の拠点間でVPNネットワークを構築するためのルーティング技術です。これは「ハブとスポーク」型のネットワークで、スポークはハブを経由せずに直接相互通信が可能です。IPsecによる暗号化がサポートされているため、通常のインターネット接続を使用して異なる拠点間を接続する際に人気の選択肢となっています。

Milesight産業用ルーターはDMVPN機能をサポートし、クライアントモードとして動作します。このマニュアルでは、DMVPNサーバーのインストール方法、およびMilesightルーターをサーバーに接続する手順を説明します。

注意:Milesightルーターのファームウェアを最新バージョンに更新してください。

要件

Ubuntu

Milesightルーター

URルーターIP:192.168.22.105

DMVPN ハブ: 192.168.23.206

GRE ハブ IP: 10.0.0.1

GRE トンネル IP: 10.0.0.XX (10.0.0.2-10.0.0.254)

GRE キー: 123456, 事前共有キー: 123456

内容

DMVPN サーバー設定

Milesight ルーター設定

接続状態の確認

設定

DMVPN サーバー設定

ステップ1. 必要環境のインストール

1.Ubuntu にログインし、以下のコマンドを実行: apt-get update

root@ubuntu:~# apt-get update
HTML

2. racoon のインストール

root@ubuntu:~# apt-get install racoon
HTML

3.opsec-tools のインストール.

root@ubuntu:~# apt-get install ipsec-tools
HTML

4: build-essential をインストールします。

root@ubuntu:~# apt-get install build-essential
HTML

5: libc-ares-dev をインストールします。

root@ubuntu:~# apt-get install libc-ares-dev
HTML

6: pkg-config をインストールします。

root@ubuntu:~# apt-get install pkg-config
HTML

7: この URL から opennhrp-0.14.1.tar.bz2 をダウンロードします。

8: opennhrp をインストールします。tar -xjvf opennhrp-0.14.1.tar.tz2 & make & make install

root@ubuntu:~# tar xjvf opennhrp-0.14.1.tar.bz2
root@ubuntu:~# cd opennhrp-0.14.1
root@ubuntu:~/opennhrp-0.14.1# ls
AUTHORS contrib doc etc libev Makefile Make.rules man MIT-LICENSE.txt NEWS nhrp patches README TODO
root@ubuntu:~/opennhrp-0.14.1# make
root@ubuntu:~/opennhrp-0.14.1# make install
install -d /usr/sbin
install nhrp/opennhrp nhrp/opennhrpctl /usr/sbin
install -d /etc/opennhrp
install etc/opennhrp.conf etc/opennhrp-script etc/racoon-ph1down.sh etc/racoon-ph1dead.sh /etc/opennhrp
install -d /usr/share/man/man5 /usr/share/man/man8
install man/opennhrp.conf.5 /usr/share/man/man5
install man/opennhrp.8 man/opennhrpctl.8 man/opennhrp-script.8 /usr/share/man/man8
install -d /usr/share/doc/opennhrp
install README /usr/share/doc/opennhrp
C

ステップ2. /etc/opennhrp/opennhrp.conf を設定

root@ubuntu:/etc/opennhrp# cat opennhrp.conf
interface gre1
  shortcut
  redirect
  non-caching
  multicast nhs
C

ステップ3. /etc/racoon/racoon.conf を設定

root@ubuntu:/etc/racoon# cat racoon.conf
path include "/etc/racoon/";
path pre_shared_key "/etc/racoon/psk.txt";
remote anonymous {
    exchange_mode main;
    lifetime time 10800 seconds;
    my_identifier address;
    dpd_delay 30;
    dpd_retry 3;
    dpd_maxfail 6;
    nat_traversal on;
    proposal {
            encryption_algorithm des;
            hash_algorithm sha1;
            dh_group modp768;
            authentication_method pre_shared_key;
    }
}
sainfo anonymous {
    lifetime time 3600 seconds;
    compression_algorithm deflate;
    encryption_algorithm 3des;
    authentication_algorithm hmac_sha1;
}
C

ステップ4. /etc/racoon/psk.txt を設定

注: ルーターのWAN IPアドレスに応じてIPアドレスを設定してください

Step5. ipsec-tools.conf を設定

root@ubuntu:/# cat /etc/ipsec-tools.conf
#!/usr/sbin/setkey -f
 flush;
 spdflush;
 spdadd 0.0.0.0/0 0.0.0.0/0 gre -P out ipsec esp/transport//require;
 spdadd 0.0.0.0/0 0.0.0.0/0 gre -P in  ipsec esp/transport//require;
C

ステップ6. DMVPN を開始/停止するスクリプトを作成します

注: サーバーの IP アドレスに応じてローカル IP アドレスを設定してください

root@ubuntu:/# cat dmvpn.sh
#!/bin/sh
    start_nhrp() {
    opennhrp -d
    }
    stop_nhrp() {
        killall -9 opennhrp
             }
    start_gre1() {
    ip tunnel add gre1 mode gre local 192.168.23.206 key 123456 ttl 64
    ip addr add 10.0.0.1/24 dev gre1
    ip link set gre1 up multicast on
    }
    stop_gre1() {
        ifconfig gre1 down
        ip tunnel del gre1
             }
    start_ipsec() {
        setkey -f /etc/ipsec-tools.conf
        racoon -f /etc/racoon/racoon.conf
             }
    stop_ipsec() {
        setkey -F
        setkey -FP
        killall -9 racoon
             }
    ACTION="$1"
    if [ "$ACTION" = "start" ];then
        start_gre1
        start_ipsec
        start_nhrp
    fi
    if [ "$ACTION" = "stop" ];then
        stop_nhrp
        stop_gre1
        stop_ipsec
    fi
C

ステップ7. 作成したスクリプトでサービスを起動する

root@ubuntu:~# chmod +x dmvpn.sh
root@ubuntu:~# ./dmvpn.sh start
opennhrp[19850]: OpenNHRP 0.14.1 starting
opennhrp[19850]: Interface lo: configured UP, mtu=0
opennhrp[19850]: Interface ens18: configured UP, mtu=1500
opennhrp[19850]: Interface gre0: config change, mtu=1476
opennhrp[19850]: Interface gretap0: config change, mtu=1462
opennhrp[19850]: Interface gre1: configured UP, mtu=1472
opennhrp[19850]: Interface gre1: GRE configuration changed. Purged 0 peers.
opennhrp[19850]: Filter code installed (21 opcodes)
C

Milesight ルーターの設定

DMVPN を有効にし、設定を保存して適用してください。

接続状態を確認

Milesight ルーターの Web GUI で Status -> VPN に移動してください。

関連記事

ルーターの使用

ソリューション / IoT サポート


    Milesight製品

    ウェーブクレスト株式会社が運営するMilesight製品特設サイトです

    居住者の健康を確保

    お知らせ

    1. 2025-4-3

      ピープル・センシング 駆動型スマートビルディング

      People Sensing Insights を通じてビルインテリジェンスに革命をもたらします。…
    2. 2023-7-21

      LoRaWANの説明: 理論から実践へのガイド

      この包括的なビデオでは、LoRaWANを深く掘り下げ、その仕組み、利点、アプリケーションについて説明…
    3. 2023-4-6

      センシング・インサイト Milesight リブランディングのお知らせ

      https://youtu.be/r40DK40DjIY …
    ページ上部へ戻る