WireGuardのインストール

reTerminal(ラズパイ互換)にWireGuardをインストールしてSORACOM Arcに繋いでみます。

参考URL

ドキュメントはこれ。

users.soracom.io

SORACOM AirにバーチャルSIMを追加

ドキュメントを参考に、バーチャルSIMを追加します。

f:id:matsujirushix:20211124212453p:plain

追加の際に、忘れずに接続情報を取っておきます。

f:id:matsujirushix:20211124212929p:plain

WireGuardをインストール

aptでサクッとインストールします。

pi@raspberrypi:~ $ sudo apt install wireguard
(略)

SORACOMに接続

WireGuardの接続情報を追加します。
バーチャルSIMを追加したときに取得した接続情報を、そのまま/etc/wireguard/wg0.confに設定すればOKです。

pi@raspberrypi:~ $ sudo vi /etc/wireguard/wg0.conf

で、接続はwg-quick upで起動します。

pi@raspberrypi:~ $ sudo wg-quick up wg0
[#] ip link add wg0 type wireguard
[#] wg setconf wg0 /dev/fd/63
[#] ip -4 address add 10.226.92.0/32 dev wg0
[#] ip link set mtu 1420 up dev wg0
[#] ip -4 route add 100.127.0.0/16 dev wg0
pi@raspberrypi:~ $ 

ちなみに、ip rでルーティング情報を確認すると、接続前は

pi@raspberrypi:~ $ ip r
default via 192.168.1.1 dev eth0 proto dhcp metric 100 
default via 192.168.1.1 dev eth0 proto dhcp src 192.168.1.102 metric 202 
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.102 metric 100 
192.168.1.0/24 dev eth0 proto dhcp scope link src 192.168.1.102 metric 202 
pi@raspberrypi:~ $ 

で、接続後は、

pi@raspberrypi:~ $ ip r
default via 192.168.1.1 dev eth0 proto dhcp metric 100 
default via 192.168.1.1 dev eth0 proto dhcp src 192.168.1.102 metric 202 
100.127.0.0/16 dev wg0 scope link 
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.102 metric 100 
192.168.1.0/24 dev eth0 proto dhcp scope link src 192.168.1.102 metric 202 
pi@raspberrypi:~ $

と、100.127.0.0/16 dev wg0 scope linkが追加されました。

SORACOMとの通信確認

pingが通ればOK。

pi@raspberrypi:~ $ ping pong.soracom.io
PING pong.soracom.io (100.127.100.127) 56(84) bytes of data.
64 bytes from 100.127.100.127 (100.127.100.127): icmp_seq=1 ttl=64 time=37.0 ms
64 bytes from 100.127.100.127 (100.127.100.127): icmp_seq=2 ttl=64 time=17.4 ms
(略)