1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VyOS で OSPF

1
Last updated at Posted at 2026-03-01

目的

勉強のために OSPF をやってみないか?
ということで、以下手順でネットワークを作ってみる。

  1. 各ルーターへ共通設定を入れ、管理ポートを繋ぐ
  2. 拠点間を PPPoE で繋ぐ
  3. WAN を模して PPPoE に遅延を入れる
  4. 拠点間を IPsec で繋ぐ
  5. 拠点間を OSPF でルーティングする

最終的にルーター 3台が PPPoE 上の IPsec を経由して接続され、センタールーターからインターネットへ抜けるネットワークになる。(センタールーターを中心とする HUB-spoke 型)

構成図

image.png

インターフェースとセグメント

if名 役割
eth0 管理用
eth1 PPPoE 通信用
eth2 LAN
eth3 RT99 のインターネット回線
pppoe0 PPPoE クライアント(eth1へ流す)
vtiNN IPsec 通信用
セグメント 役割
192.168.0.0/24 管理・インターネット接続
100.64.0.0/24 PPPoE 用
100.64.1.0/24 VPN 用
100.64.10.0/24 拠点 10
100.64.20.0/24 拠点 20
100.64.99.0/24 センター拠点

EVE-NG の Tips

EVE-NG 上の VyOS で作成していきます。
※ブリッジの Type を変更すると動作がおかしくなることがある。Typeを変更するときはケーブルをすべて外してからにしましょう。良くわからなくなったときは EVE-NG ごと再起動すると良いです。 (多分、有償版であれば問題なく使えると思う)
image.png

共通設定と、管理ポート

図に線は引いていないが、ssh でリモートログインできるよう、それぞれのルーターへ管理ポートを接続する (vrf MGT)

共通設定

configure
load /opt/vyatta/etc/config.boot.default

delete interfaces
delete service
delete nat
delete protocols
delete vpn
delete vrf
delete protocols static

set system domain-name 'my.home'
set system time-zone 'Asia/Tokyo'
set system ipv6 disable-forwarding
set system option kernel disable-mitigations
set system option performance virtual-guest

set vrf name MGT table '100'

set interfaces ethernet eth0 vrf MGT
set vrf name MGT protocols static route 0.0.0.0/0 next-hop 192.168.0.254

set service lldp interface all
set service lldp legacy-protocols cdp
set system ipv6 disable-forwarding

set system name-server 192.168.0.252
set system name-server 1.0.0.1

set service ntp vrf MGT
set service ntp server 192.168.0.254
set service ntp server 192.168.0.252
set service ssh vrf MGT

ホスト名と管理ポート設定

ホスト名と、管理ポートの IP はそれぞれ変更する

RT99

set system host-name RT99
set interfaces ethernet eth0 address 192.168.0.99/24

RT10

set system host-name RT10
set interfaces ethernet eth0 address 192.168.0.98/24

RT20

set system host-name RT20
set interfaces ethernet eth0 address 192.168.0.97/24

PPPoE サーバ

set system host-name 'PPPoE'
set interfaces ethernet eth0 address 192.168.0.90/24

PPPoE 接続

PPPoEサーバーを作る

https://claude.ai/public/artifacts/017d21f7-80a8-4df0-b9b9-a81dfa4c51a0
を使って PPPoE サーバーを作成する。

入力パラメータ

この PPPoE 接続からは直接インターネットへ出ないので (フレッツ VPN など) 「上流側を使用する」はチェックを外しておく。

インターフェース : eth1
ゲートウェイアドレス : 100.64.0.0

id/pass と PPPoE クライアントのアドレス。パスワードはここだけの、内緒ですよ。

user99,pass99,100.64.0.99/32
user10,pass10,100.64.0.10/32
user20,pass20,100.64.0.20/32

一番下の「設定ファイル生成」をクリックして出力された設定は共通部分の設定と重複するものを削って以下の通り

set system host-name 'PPPoE'

# PPPoE側設定
set interfaces ethernet eth1 description 'PPPoE-Server'
set service pppoe-server interface eth1
set service pppoe-server access-concentrator PPPoE-Server
set service pppoe-server authentication mode 'local'
set service pppoe-server client-ip-pool PPPOE-POOL range 100.64.10.0-100.64.10.10
set service pppoe-server default-pool 'PPPOE-POOL'
set service pppoe-server gateway-address '100.64.0.0'
set service pppoe-server ppp-options disable-ccp
set service pppoe-server ppp-options ipv4 'prefer'
set service pppoe-server ppp-options lcp-echo-failure '5'
set service pppoe-server ppp-options lcp-echo-interval '5'
set service pppoe-server ppp-options min-mtu '1000'
set service pppoe-server mtu '1454'
set service pppoe-server ppp-options mru '1454'
# 1アカウントで複数セッション可能
set service pppoe-server session-control 'disable'

# ユーザー情報
set service pppoe-server authentication local-users username user99 password 'pass99'
set service pppoe-server authentication local-users username user99 static-ip 100.64.0.99
set service pppoe-server authentication local-users username user10 password 'pass10'
set service pppoe-server authentication local-users username user10 static-ip 100.64.0.10
set service pppoe-server authentication local-users username user20 password 'pass20'
set service pppoe-server authentication local-users username user20 static-ip 100.64.0.20
commit ; save ; exit
true

mtu (最大送信パケットサイズ), mru (最大受信可能パケットサイズ) はフレッツ回線に準じた値 (1454) にしています。

PPPoE クライアントの設定

RT99, RT10, RT20 それぞれ PPPoE 接続する

共通設定

# eth0: PPPoE クライアント用インターフェース
set interfaces ethernet eth1 description 'PPPoE'

# PPPoE クライアント設定
set interfaces pppoe pppoe0 default-route 10
set interfaces pppoe pppoe0 mtu '1492'
set interfaces pppoe pppoe0 source-interface 'eth1'
set interfaces pppoe pppoe0 no-default-route
set interfaces pppoe pppoe0 no-peer-dns
set protocols static route 100.64.0.0/24 interface pppoe0

RT99 (センタールーター)

# PPPoE 設定
set interfaces pppoe pppoe0 authentication username 'user99'
set interfaces pppoe pppoe0 authentication password 'pass99'
# LAN 設定
set interfaces ethernet eth2 address '100.64.99.1/24'
set interfaces ethernet eth2 description 'LAN'

RT10 (拠点 10)

# PPPoE 設定
set interfaces pppoe pppoe0 authentication username 'user10'
set interfaces pppoe pppoe0 authentication password 'pass10'
# LAN 設定
set interfaces ethernet eth2 address '100.64.10.1/24'
set interfaces ethernet eth2 description 'LAN'

RT20 (拠点 20)

# PPPoE 設定
set interfaces pppoe pppoe0 authentication username 'user20'
set interfaces pppoe pppoe0 authentication password 'pass20'
# LAN 設定
set interfaces ethernet eth2 address '100.64.20.1/24'
set interfaces ethernet eth2 description 'LAN'

PPPoE 接続確認

PPPoE サーバー

PPPoE のセッションが見えて、 /32 で対向へ接続されていること。

vyos@PPPoE:~$ show pppoe-server sessions
 ifname | username |     ip      | ip6 | ip6-dp |    calling-sid    | rate-limit | state  |  uptime  | rx-bytes | tx-bytes
--------+----------+-------------+-----+--------+-------------------+------------+--------+----------+----------+----------
 ppp0   | user10   | 100.64.0.10 |     |        | 50:00:00:03:00:01 |            | active | 00:02:59 | 14.7 KiB | 15.1 KiB
 ppp1   | user20   | 100.64.0.20 |     |        | 50:00:00:04:00:01 |            | active | 00:02:53 | 13.7 KiB | 15.3 KiB
 ppp2   | user99   | 100.64.0.99 |     |        | 50:00:00:02:00:01 |            | active | 00:02:53 | 30.5 KiB | 27.2 KiB
vyos@PPPoE:~$
vyos@PPPoE:~$ show ip route
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
L * 100.64.0.0/32 is directly connected, ppp2, weight 1, 00:05:13
L * 100.64.0.0/32 is directly connected, ppp1, weight 1, 00:05:16
L>* 100.64.0.0/32 is directly connected, ppp0, weight 1, 00:05:19
C>* 100.64.0.10/32 is directly connected, ppp0, weight 1, 00:05:19
C>* 100.64.0.20/32 is directly connected, ppp1, weight 1, 00:05:16
C>* 100.64.0.99/32 is directly connected, ppp2, weight 1, 00:05:13
vyos@PPPoE:~$
vyos@PPPoE:~$ show log | grep -i ppp
Apr 04 03:36:50 accel-pppoe[2075]: ppp0:user10: connect: ppp0 <--> pppoe(50:00:00:03:00:01)
Apr 04 03:36:50 accel-pppoe[2075]: ppp0:user10: user10: authentication succeeded
Apr 04 03:36:53 accel-pppoe[2075]: ppp1:user20: connect: ppp1 <--> pppoe(50:00:00:04:00:01)
Apr 04 03:36:53 accel-pppoe[2075]: ppp1:user20: user20: authentication succeeded
Apr 04 03:36:56 accel-pppoe[2075]: ppp2:user99: connect: ppp2 <--> pppoe(50:00:00:02:00:01)
Apr 04 03:36:56 accel-pppoe[2075]: ppp2:user99: user99: authentication succeeded
vyos@PPPoE:~$

RT10 クライアント

pppoe が u/u になっていること。show interfaces pppoe pppoe0 log では tail -f 的なログも見える。
トラブル時は show log | grep -i ppp の方が詳細なログが見えます。

vyos@RT99:~$ show interfaces pppoe
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
pppoe0           100.64.0.99/32                    u/u
vyos@RT99:~$
vyos@RT99:~$ show interfaces pppoe pppoe0 log
Apr 04 03:36:58 pppd[2022]: rcvd [LCP EchoReq id=0xb0 magic=0xdf43f6f]
Apr 04 03:36:58 pppd[2022]: sent [LCP EchoRep id=0xb0 magic=0x611715f7]
Apr 04 03:36:59 pppd[2022]: rcvd [IPCP ConfReq id=0x78 <addr 100.64.0.0>]
Apr 04 03:36:59 pppd[2022]: sent [IPCP ConfAck id=0x78 <addr 100.64.0.0>]
Apr 04 03:36:59 pppd[2022]: Script /etc/ppp/ip-pre-up started (pid 3016)
Apr 04 03:36:59 pppd[2022]: Script /etc/ppp/ip-pre-up finished (pid 3016), status = 0x0
Apr 04 03:36:59 pppd[2022]: local  IP address 100.64.0.99
Apr 04 03:36:59 pppd[2022]: remote IP address 100.64.0.0
Apr 04 03:36:59 pppd[2022]: Script /etc/ppp/ip-up started (pid 3019)
Apr 04 03:37:01 pppd[2022]: Script /etc/ppp/ip-up finished (pid 3019), status = 0x0

センター (RT99) からインターネットへ

NAT して、インターネットへ出ていく

# eth3: 上流
set interfaces ethernet eth3 address '192.168.0.91/24'
set interfaces ethernet eth3 description 'Internet'
set protocols static route 0.0.0.0/0 next-hop 192.168.0.254

set nat source rule 100 outbound-interface name 'eth3'
set nat source rule 100 translation address 'masquerade'

通信試験用の PC を周辺に置く

image.png

ホスト名と IP アドレスを設定し、ルーターまで接続できることを確認する。

VPCS> set pcname PC99

PC99> ip 100.64.99.3/24 100.64.99.1
Checking for duplicate address...
VPCS : 100.64.99.3 255.255.255.0 gateway 100.64.99.1

PC99> ping 100.64.99.1

84 bytes from 100.64.99.1 icmp_seq=1 ttl=64 time=0.397 ms
84 bytes from 100.64.99.1 icmp_seq=2 ttl=64 time=0.318 ms
84 bytes from 100.64.99.1 icmp_seq=3 ttl=64 time=0.309 ms
^C

###---- PC10用設定
set pcname PC10
ip 100.64.10.3/24 100.64.10.1

###---- PC20用設定
set pcname PC20
ip 100.64.20.3/24 100.64.20.1

PPPoE サーバーに遅延を入れる

WAN 回線を模して「遅延 20ms、ジッター 5ms」を入れる
VyOS のコマンドでは扱えないので、tc コマンドを使う
この設定は再起動すると消えるので、保存する場合は /config/scripts/vyos-postconfig-bootup.script へ記入する。

eth1 の出力方向

sudo tc qdisc replace dev eth1 root netem delay 20ms 5ms
--- 変更する場合は change を使う
sudo tc qdisc change dev eth1 root netem delay 20ms 5ms

eth1 の入力方向

遅延は出力側にしか掛けることができないので、入力は ifb0 を経由させて遅延させる。

一度アンロードする(既存の ifb を削除)

sudo modprobe -r ifb

1つ(ifb0)を作成するように指定してモジュールをロード

sudo modprobe ifb numifbs=1

起動

sudo ip link set dev ifb0 up

eth1 の受信口を作成

sudo tc qdisc add dev eth1 handle ffff: ingress

パケットを ifb0 へ転送 (処理が終わると eth1 へ戻す)

sudo tc filter add dev eth1 parent ffff: protocol all u32 match u32 0 0 action mirred egress redirect dev ifb0

ifb0 に対して 20ms ± 5ms の遅延を設定

sudo tc qdisc add dev ifb0 root netem delay 20ms 5ms

設定の確認

vyos@PPPoE:~$ sudo tc -s qdisc show dev eth1
qdisc netem 8002: root refcnt 2 limit 1000 delay 20ms  5ms seed 4821445404563938634
 Sent 135166 bytes 1361 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
qdisc ingress ffff: parent ffff:fff1 ----------------
 Sent 67934 bytes 819 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
vyos@PPPoE:~$
vyos@PPPoE:~$ sudo tc -s qdisc show dev ifb0
qdisc netem 8003: root refcnt 2 limit 1000 delay 20ms  5ms seed 6548969526654248316
 Sent 86392 bytes 858 pkt (dropped 0, overlimits 0 requeues 0)
 backlog 0b 0p requeues 0
vyos@PPPoE:~$

delay 20ms 5ms で、遅延 20ms, ジッター 5ms を表している。

遅延の確認

PC20> ping 100.64.99.1

84 bytes from 100.64.99.1 icmp_seq=1 ttl=63 time=80.294 ms
84 bytes from 100.64.99.1 icmp_seq=2 ttl=63 time=88.537 ms
84 bytes from 100.64.99.1 icmp_seq=3 ttl=63 time=78.345 ms
84 bytes from 100.64.99.1 icmp_seq=4 ttl=63 time=83.004 ms
84 bytes from 100.64.99.1 icmp_seq=5 ttl=63 time=80.952 ms

PC20>

ping の time は往復時間なので
RT20 ①→ PPPoE ②→ RT99 (行き)
RT20 ③← PPPoE ④← RT99 (帰り)
①~④ それぞれで遅延 20ms ± ジッター
➡️ 合計で 80ms ± 20ms 程度の遅延

VPN を接続する (IKEv2)

vti インターフェースを作成して、お互いにトンネルを張る。

ルータ if アドレス 対向
RT99 vti10 100.64.1.11/31 RT10 : vti99
RT99 vti20 100.64.1.21/31 RT20 : vti99
RT10 vti99 100.64.1.10/31 RT99 : vti10
RT20 vti99 100.64.1.20/31 RT99 : vti20

※ vti <NN> の番号は対向のルーターの番号

  • PSK で接続し、ここでは「secret_ABC-def」とします。いわゆるパスワードなので、ここだけの秘密にしておいてくださいね。 (PSK = pre shared key : 事前共有鍵)
  • set interfaces vti vtiNN ip adjust-mss 'clamp-mss-to-pmtu'VTI を通る TCP 通信の MSS を PMTU に合わせて自動調整。UDP, ICMP のパケットサイズは調整しない。

共通設定

# IPsec (IKE Phase 1 = IKE / IKE Phase 2 = ESP)
set vpn ipsec esp-group IPsec_ESP lifetime '3600'
set vpn ipsec esp-group IPsec_ESP mode 'tunnel'
set vpn ipsec esp-group IPsec_ESP pfs 'dh-group31'
set vpn ipsec esp-group IPsec_ESP proposal 1 encryption 'chacha20poly1305'
set vpn ipsec esp-group IPsec_ESP proposal 1 hash 'aes256gmac'
set vpn ipsec ike-group IPsec_IKE dead-peer-detection action 'restart'
set vpn ipsec ike-group IPsec_IKE dead-peer-detection interval '15'
set vpn ipsec ike-group IPsec_IKE dead-peer-detection timeout '60'
set vpn ipsec ike-group IPsec_IKE key-exchange 'ikev2'
set vpn ipsec ike-group IPsec_IKE lifetime '28800'
set vpn ipsec ike-group IPsec_IKE proposal 1 dh-group '31'
set vpn ipsec ike-group IPsec_IKE proposal 1 encryption 'chacha20poly1305'
set vpn ipsec ike-group IPsec_IKE proposal 1 hash 'aes256gmac'
set vpn ipsec ike-group IPsec_IKE proposal 1 prf 'prfsha512'
set vpn ipsec interface 'pppoe0'
set vpn ipsec options disable-route-autoinstall

RT99 センタールータ

※ 実環境の secret は 32文字以上、openssl rand -base64 32 など、ランダムなものを使いましょう。と、Gemini に指摘されました。実運用は

###---- RT99 から RT10
set vpn ipsec authentication psk TR99-to-RT10 id 'RT99'
set vpn ipsec authentication psk TR99-to-RT10 id 'RT10'
set vpn ipsec authentication psk TR99-to-RT10 secret 'secret_ABC-def'

set vpn ipsec site-to-site peer TR99-to-RT10 authentication local-id 'RT99'
set vpn ipsec site-to-site peer TR99-to-RT10 authentication mode 'pre-shared-secret'
set vpn ipsec site-to-site peer TR99-to-RT10 authentication remote-id 'RT10'
set vpn ipsec site-to-site peer TR99-to-RT10 connection-type 'initiate'
set vpn ipsec site-to-site peer TR99-to-RT10 ike-group 'IPsec_IKE'
set vpn ipsec site-to-site peer TR99-to-RT10 ikev2-reauth 'inherit'
set vpn ipsec site-to-site peer TR99-to-RT10 local-address '100.64.0.99'
set vpn ipsec site-to-site peer TR99-to-RT10 remote-address '100.64.0.10'
set vpn ipsec site-to-site peer TR99-to-RT10 vti bind 'vti10'
set vpn ipsec site-to-site peer TR99-to-RT10 vti esp-group 'IPsec_ESP'
set interfaces vti vti10 address '100.64.1.11/31'
set interfaces vti vti10 description 'RT99-to-RT10_tunnel'
set interfaces vti vti10 ip adjust-mss 'clamp-mss-to-pmtu'
set protocols static route 100.64.1.10/32 interface vti10

###---- RT99 から RT20
set vpn ipsec authentication psk TR99-to-RT20 id 'RT99'
set vpn ipsec authentication psk TR99-to-RT20 id 'RT20'
set vpn ipsec authentication psk TR99-to-RT20 secret 'secret_ABC-def'

set vpn ipsec site-to-site peer TR99-to-RT20 authentication local-id 'RT99'
set vpn ipsec site-to-site peer TR99-to-RT20 authentication mode 'pre-shared-secret'
set vpn ipsec site-to-site peer TR99-to-RT20 authentication remote-id 'RT20'
set vpn ipsec site-to-site peer TR99-to-RT20 connection-type 'initiate'
set vpn ipsec site-to-site peer TR99-to-RT20 ike-group 'IPsec_IKE'
set vpn ipsec site-to-site peer TR99-to-RT20 ikev2-reauth 'inherit'
set vpn ipsec site-to-site peer TR99-to-RT20 local-address '100.64.0.99'
set vpn ipsec site-to-site peer TR99-to-RT20 remote-address '100.64.0.20'
set vpn ipsec site-to-site peer TR99-to-RT20 vti bind 'vti20'
set vpn ipsec site-to-site peer TR99-to-RT20 vti esp-group 'IPsec_ESP'
set interfaces vti vti20 address '100.64.1.21/31'
set interfaces vti vti20 description 'RT99-to-RT20_tunnel'
set interfaces vti vti20 ip adjust-mss 'clamp-mss-to-pmtu'
set protocols static route 100.64.1.20/32 interface vti20

RT10 (拠点 10)

###---- RT10 から RT99
set vpn ipsec authentication psk TR10-to-RT99 id 'RT10'
set vpn ipsec authentication psk TR10-to-RT99 id 'RT99'
set vpn ipsec authentication psk TR10-to-RT99 secret 'secret_ABC-def'

set vpn ipsec site-to-site peer TR10-to-RT99 authentication local-id 'RT10'
set vpn ipsec site-to-site peer TR10-to-RT99 authentication mode 'pre-shared-secret'
set vpn ipsec site-to-site peer TR10-to-RT99 authentication remote-id 'RT99'
set vpn ipsec site-to-site peer TR10-to-RT99 connection-type 'initiate'
set vpn ipsec site-to-site peer TR10-to-RT99 ike-group 'IPsec_IKE'
set vpn ipsec site-to-site peer TR10-to-RT99 ikev2-reauth 'inherit'
set vpn ipsec site-to-site peer TR10-to-RT99 local-address '100.64.0.10'
set vpn ipsec site-to-site peer TR10-to-RT99 remote-address '100.64.0.99'
set vpn ipsec site-to-site peer TR10-to-RT99 vti bind 'vti99'
set vpn ipsec site-to-site peer TR10-to-RT99 vti esp-group 'IPsec_ESP'
set interfaces vti vti99 address '100.64.1.10/31'
set interfaces vti vti99 description 'RT10-to-RT99_tunnel'
set interfaces vti vti99 ip adjust-mss 'clamp-mss-to-pmtu'
set protocols static route 100.64.1.11/32 interface vti99

RT20 (拠点20)

###---- RT20 から RT99
set vpn ipsec authentication psk TR20-to-RT99 id 'RT20'
set vpn ipsec authentication psk TR20-to-RT99 id 'RT99'
set vpn ipsec authentication psk TR20-to-RT99 secret 'secret_ABC-def'

set vpn ipsec site-to-site peer TR20-to-RT99 authentication local-id 'RT20'
set vpn ipsec site-to-site peer TR20-to-RT99 authentication mode 'pre-shared-secret'
set vpn ipsec site-to-site peer TR20-to-RT99 authentication remote-id 'RT99'
set vpn ipsec site-to-site peer TR20-to-RT99 connection-type 'initiate'
set vpn ipsec site-to-site peer TR20-to-RT99 ike-group 'IPsec_IKE'
set vpn ipsec site-to-site peer TR20-to-RT99 ikev2-reauth 'inherit'
set vpn ipsec site-to-site peer TR20-to-RT99 local-address '100.64.0.20'
set vpn ipsec site-to-site peer TR20-to-RT99 remote-address '100.64.0.99'
set vpn ipsec site-to-site peer TR20-to-RT99 vti bind 'vti99'
set vpn ipsec site-to-site peer TR20-to-RT99 vti esp-group 'IPsec_ESP'
set interfaces vti vti99 address '100.64.1.20/31'
set interfaces vti vti99 description 'RT20-to-RT99_tunnel'
set interfaces vti vti99 ip adjust-mss 'clamp-mss-to-pmtu'
set protocols static route 100.64.1.21/32 interface vti99

接続状態の確認

トンネルが張られていて、トンネルの対向へ ping が通ることを確認する。

vyos@RT99:~$ show vpn ipsec sa
Connection        State    Uptime    Bytes In/Out    Packets In/Out    Remote address    Remote ID    Proposal
----------------  -------  --------  --------------  ----------------  ----------------  -----------  -----------------------------
TR99-to-RT10-vti  up       15m5s     6K/6K           96/96             100.64.0.10       RT10         CHACHA20_POLY1305/CURVE_25519
TR99-to-RT20-vti  up       18m51s    7K/8K           119/119           100.64.0.20       RT20         CHACHA20_POLY1305/CURVE_25519

vyos@RT99:~$ show vpn ike sa
Peer ID / IP                            Local ID / IP
------------                            -------------
100.64.0.20 RT20                        100.64.0.99 RT99

    State  IKEVer  Encrypt      Hash          D-H Group      NAT-T  A-Time  L-Time
    -----  ------  -------      ----          ---------      -----  ------  ------
    up     IKEv2   CHACHA20_POLY1305 n/a           CURVE_25519    no     19076   7448

Peer ID / IP                            Local ID / IP
------------                            -------------
100.64.0.10 RT10                        100.64.0.99 RT99

    State  IKEVer  Encrypt      Hash          D-H Group      NAT-T  A-Time  L-Time
    -----  ------  -------      ----          ---------      -----  ------  ------
    up     IKEv2   CHACHA20_POLY1305 n/a           CURVE_25519    no     19074   8406

vyos@RT99:~$
vyos@RT99:~$ ping 100.64.1.10 count 4
PING 100.64.1.10 (100.64.1.10) 56(84) bytes of data.
64 bytes from 100.64.1.10: icmp_seq=1 ttl=64 time=87.7 ms
64 bytes from 100.64.1.10: icmp_seq=2 ttl=64 time=74.8 ms
64 bytes from 100.64.1.10: icmp_seq=3 ttl=64 time=73.4 ms
64 bytes from 100.64.1.10: icmp_seq=4 ttl=64 time=81.6 ms

--- 100.64.1.10 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 73.439/79.388/87.713/5.710 ms
vyos@RT99:~$
vyos@RT99:~$ ping 100.64.1.20 count 4
PING 100.64.1.20 (100.64.1.20) 56(84) bytes of data.
64 bytes from 100.64.1.20: icmp_seq=1 ttl=64 time=84.7 ms
64 bytes from 100.64.1.20: icmp_seq=2 ttl=64 time=79.9 ms
64 bytes from 100.64.1.20: icmp_seq=3 ttl=64 time=90.1 ms
64 bytes from 100.64.1.20: icmp_seq=4 ttl=64 time=78.7 ms

--- 100.64.1.20 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 78.681/83.345/90.060/4.486 ms
vyos@RT99:~$

OSPF 設定

  1. 拠点間の実データ通信を暗号化されていない経路へ出さない
    そのため、経路交換に使う OSPF も IPsec トンネル上でのみ動作させる。
    passive-interface default ですべてのインターフェースで OSPF を送受信しないようにしておき、set protocols ospf interface vtiNN passive disable で VPN 用の vti インターフェースだけを例外として OSPF を有効化する。
  2. 拠点毎にエリアを分ける。
  3. VPN 上は一対一なので point-to-point になり、その部分は DR が存在しません。DR 選出プロセスが省略されてネイバーが確立されるまでの時間がほんの少し縮まります。
エリア エリアID セグメント
バックボーンエリア
(VPN 上)
area 0.0.0.0 100.64.1.0/24
センター拠点 LAN area 100.64.99.0 100.64.99.0/24
拠点10 LAN area 100.64.10.0 100.64.10.0/24
拠点20 LAN area 100.64.20.0 100.64.20.0/24

RT99 (センタールータ)

set protocols ospf default-information originate	👈 デフォルトルートを OSPF へ注入
set protocols ospf area 0.0.0.0 network '100.64.1.0/24'	👈 バックボーンに vpn のセグメントを指定
set protocols ospf area 100.64.99.0 network '100.64.99.0/24'	👈 LAN セグメントも OSPF へ流す
set protocols ospf interface vti10 network 'point-to-point'	👈 拠点ルーターと 1対1 で接続する (ブロードキャストでない)
set protocols ospf interface vti10 passive disable	👈 RT10 と接続
set protocols ospf interface vti20 network 'point-to-point'	👈 拠点ルーターと 1対1 で接続する
set protocols ospf interface vti20 passive disable	👈 RT20 と接続
set protocols ospf log-adjacency-changes detail
set protocols ospf passive-interface 'default'	👈 関係ないポートは OSPF を流さない

RT10

set protocols ospf area 0.0.0.0 network '100.64.1.0/24'	👈 バックボーンセグメント
set protocols ospf area 100.64.10.0 network '100.64.10.0/24'	👈 LAN セグメント
set protocols ospf interface vti99 network 'point-to-point'	👈 センタールーターと 1対1 で接続する
set protocols ospf interface vti99 passive disable	👈 RT99 と接続
set protocols ospf log-adjacency-changes detail
set protocols ospf passive-interface 'default'	👈 関係ないポートは OSPF を流さない

RT20

set protocols ospf area 0.0.0.0 network '100.64.1.0/24'	👈 バックボーンセグメント
set protocols ospf area 100.64.20.0 network '100.64.20.0/24'	👈 LAN セグメント
set protocols ospf interface vti99 network 'point-to-point'	👈 センタールーターと 1対1 で接続する
set protocols ospf interface vti99 passive disable	👈 RT99 と接続
set protocols ospf log-adjacency-changes detail
set protocols ospf passive-interface 'default'	👈 関係ないポートは OSPF を流さない

接続確認

  1. PC99➔PC10
PC99> trace 100.64.10.3
trace to 100.64.10.3, 8 hops max, press Ctrl+C to stop
 1   100.64.99.1   0.271 ms  0.163 ms  0.150 ms	👈 RT99 LAN
 2   100.64.1.10   79.949 ms  76.109 ms  90.806 ms	👈 RT10 VPN
 3   *100.64.10.3   85.961 ms (ICMP type:3, code:3, Destination port unreachable)	👈 PC10

PC99>
  1. PC10➔PC20
PC10> trace 100.64.20.3
trace to 100.64.20.3, 8 hops max, press Ctrl+C to stop
 1   100.64.10.1   0.320 ms  0.171 ms  0.186 ms	👈 RT10 LAN
 2   100.64.1.11   81.178 ms  84.034 ms  72.730 ms	👈 RT99 VPN
 3   100.64.1.20   168.246 ms  150.014 ms  155.365 ms	👈 RT20 VPN
 4   *100.64.20.3   156.666 ms (ICMP type:3, code:3, Destination port unreachable)	👈 PC20

PC10>
  1. PC20➔インターネット
PC20> trace 1.1.1.1
trace to 1.1.1.1, 8 hops max, press Ctrl+C to stop
 1   100.64.20.1   0.329 ms  0.172 ms  0.153 ms	👈 RT20 LAN
 2   100.64.1.21   83.980 ms  86.650 ms  73.894 ms	👈 RT99 VPN
 3   192.168.0.254   71.729 ms  83.589 ms  85.838 ms	👈 おうちルータ
 4   192.0.0.1   87.163 ms  91.309 ms  76.822 ms	👈 IPoE?
 5   163.139.136.74   84.574 ms  96.609 ms  86.019 ms	👈 インターネット
 6   163.139.136.106   82.351 ms  78.359 ms  80.970 ms	👈 インターネット
 7   163.139.138.21   89.752 ms  87.498 ms  81.122 ms	👈 インターネット
 8   162.158.4.20   87.018 ms  126.185 ms  99.274 ms	👈 インターネット

PC20>

OSPFの状態確認

RT99 の状態

vyos@RT99:~$ show ip ospf neighbor

Neighbor ID     Pri State           Up Time         Dead Time Address         Interface                        RXmtL RqstL DBsmL
100.64.10.1       1 Full/-          5h05m31s          31.612s 100.64.1.10     vti10:100.64.1.11                    0     0     0
100.64.20.1       1 Full/-          5h05m15s          34.279s 100.64.1.20     vti20:100.64.1.21                    0     0     0

vyos@RT99:~$

RT99 から RT10, RT20 の LAN の Neighbor ID が見えている。
point-to-point 接続なので (DR を選出しないので) StateFull/- になっている。
point-to-point でない場合は DRBDR が表示される

vyos@RT99:~$ show ip ospf route
============ OSPF network routing table ============
N    100.64.1.10/31        [1] area: 0.0.0.0
                           directly attached to vti10
N    100.64.1.20/31        [1] area: 0.0.0.0
                           directly attached to vti20
N IA 100.64.10.0/24        [2] area: 0.0.0.0
                           via 100.64.1.10, vti10
N IA 100.64.20.0/24        [2] area: 0.0.0.0
                           via 100.64.1.20, vti20
N    100.64.99.0/24        [1] area: 100.64.99.0
                           directly attached to eth2

============ OSPF router routing table =============
R    100.64.10.1           [1] area: 0.0.0.0, ABR
                           via 100.64.1.10, vti10
R    100.64.20.1           [1] area: 0.0.0.0, ABR
                           via 100.64.1.20, vti20

============ OSPF external routing table ===========

vyos@RT99:~$
vyos@RT99:~$ show ip route ospf
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
O   100.64.1.10/31 [110/1] is directly connected, vti10, weight 1, 05:08:01	👈 RT10 VPN
O   100.64.1.20/31 [110/1] is directly connected, vti20, weight 1, 05:08:01	👈 RT20 VPN
O>* 100.64.10.0/24 [110/2] via 100.64.1.10, vti10, weight 1, 05:07:21	👈 RT10 LAN
O>* 100.64.20.0/24 [110/2] via 100.64.1.20, vti20, weight 1, 05:07:06	👈 RT20 LAN
O   100.64.99.0/24 [110/1] is directly connected, eth2, weight 1, 05:27:13
vyos@RT99:~$
vyos@RT99:~$ show ip route
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
S>* 0.0.0.0/0 [1/0] via 192.168.0.254, eth3, weight 1, 05:27:17
S>* 100.64.0.0/24 [1/0] is directly connected, pppoe0, weight 1, 05:27:17
C>* 100.64.0.0/32 is directly connected, pppoe0, weight 1, 05:27:18
L>* 100.64.0.99/32 is directly connected, pppoe0, weight 1, 05:27:18
O   100.64.1.10/31 [110/1] is directly connected, vti10, weight 1, 05:08:05
C>* 100.64.1.10/31 is directly connected, vti10, weight 1, 05:27:12
L>* 100.64.1.11/32 is directly connected, vti10, weight 1, 05:27:12
O   100.64.1.20/31 [110/1] is directly connected, vti20, weight 1, 05:08:05
C>* 100.64.1.20/31 is directly connected, vti20, weight 1, 05:27:13
L>* 100.64.1.21/32 is directly connected, vti20, weight 1, 05:27:13
O>* 100.64.10.0/24 [110/2] via 100.64.1.10, vti10, weight 1, 05:07:25
O>* 100.64.20.0/24 [110/2] via 100.64.1.20, vti20, weight 1, 05:07:10
O   100.64.99.0/24 [110/1] is directly connected, eth2, weight 1, 05:27:17
C>* 100.64.99.0/24 is directly connected, eth2, weight 1, 05:27:23
L>* 100.64.99.1/32 is directly connected, eth2, weight 1, 05:27:23
C>* 192.168.0.0/24 is directly connected, eth3, weight 1, 05:27:24
L>* 192.168.0.91/32 is directly connected, eth3, weight 1, 05:27:24
vyos@RT99:~$

RT99 上で RT10, RT20 向けのルーティングが見えている。

RT20 の情報

vyos@RT20:~$ show ip ospf database

       OSPF Router with ID (100.64.20.1)	👈 ルータ ID 100.64.20.1 の情報

                Router Link States (Area 0.0.0.0)	👈 バックボーンエリアに所属しているルーターの一覧

Link ID         ADV Router      Age  Seq#       CkSum  Link count
100.64.10.1    100.64.10.1     1154 0x8000000e 0x248e 2
100.64.20.1    100.64.20.1      926 0x8000000e 0xd8b1 2
192.168.0.91   192.168.0.91     767 0x80000013 0xfb4c 4

                Summary Link States (Area 0.0.0.0)	👈 他のエリアから 0.0.0.0 へ入ってきたルート

Link ID         ADV Router      Age  Seq#       CkSum  Route
100.64.10.0    100.64.10.1     1004 0x8000000c 0xfef3 100.64.10.0/24	👈 RT10 LAN
100.64.20.0    100.64.20.1      946 0x8000000c 0x4a94 100.64.20.0/24	👈 RT20 LAN
100.64.99.0    192.168.0.91    1057 0x8000000c 0xcdb6 100.64.99.0/24	👈 RT99 LAN

                Router Link States (Area 100.64.20.0)	👈 Area 100.64.20.0 に所属しているルータ

Link ID         ADV Router      Age  Seq#       CkSum  Link count
100.64.20.1    100.64.20.1     1036 0x80000012 0x14ff 1

                Summary Link States (Area 100.64.20.0)	👈 他のエリアから 100.64.20.0 へ入ってきたルート

Link ID         ADV Router      Age  Seq#       CkSum  Route
100.64.1.10    100.64.20.1     1036 0x8000000c 0xbb2c 100.64.1.10/31	👈 100.64.1.10 には 100.64.20.1 
100.64.1.20    100.64.20.1     1026 0x8000000c 0x4d91 100.64.1.20/31	👈 VPN addr
100.64.10.0    100.64.20.1      966 0x8000000c 0xcc1a 100.64.10.0/24	👈 RT10 LAN
100.64.99.0    100.64.20.1     1036 0x8000000c 0xeba2 100.64.99.0/24	👈 RT99 LAN

                ASBR-Summary Link States (Area 100.64.20.0)	👈 AS External Link へのルート

Link ID         ADV Router      Age  Seq#       CkSum
192.168.0.91   100.64.20.1      656 0x8000000d 0xefe0

                AS External Link States	👈 OSPF のルーティングの外へ出る

Link ID         ADV Router      Age  Seq#       CkSum  Route
0.0.0.0        192.168.0.91     637 0x8000000e 0xfcf9 E2 0.0.0.0/0 [0x0]

vyos@RT20:~$
vyos@RT20:~$ show ip route ospf
Codes: K - kernel route, C - connected, L - local, S - static,
       R - RIP, O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
       f - OpenFabric, t - Table-Direct,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

IPv4 unicast VRF default:
O>* 0.0.0.0/0 [110/10] via 100.64.1.21, vti99, weight 1, 06:04:55	👈 OSPF からデフォルトルートを取得
O>* 100.64.1.10/31 [110/2] via 100.64.1.21, vti99, weight 1, 06:10:14	👈 RT10 VPN
O   100.64.1.20/31 [110/1] is directly connected, vti99, weight 1, 06:10:20	👈 RT20 VPN
O>* 100.64.10.0/24 [110/3] via 100.64.1.21, vti99, weight 1, 06:10:14	👈 RT10 LAN
O   100.64.20.0/24 [110/1] is directly connected, eth2, weight 1, 06:46:52	👈 RT20 LAN
O>* 100.64.99.0/24 [110/2] via 100.64.1.21, vti99, weight 1, 06:10:14	👈 RT99 LAN
vyos@RT20:~$

Link ID : 192.168.0.91Router ID として一番大きいIPアドレスが自動選出された

VyOS の最新ドキュメントを作成する

おまけ

VyOS のドキュメントも github で管理されている。そして、見てみると html ドキュメントの作成方法が書かれてある。👇

git clone https://github.com/vyos/vyos-documentation.git
cd vyos-documentation
docker run --rm -it -v "$(pwd)":/vyos -w /vyos/docs -e GOSU_UID=$(id -u) -e GOSU_GID=$(id -g) vyos/vyos-documentation make html

# (HTML ドキュメントを作成して Web ページを開ける)
docker run --rm -it -p 8000:8000 -v "$(pwd)":/vyos -w /vyos/docs -e GOSU_UID=$(id -u) -e GOSU_GID=$(id -g) vyos/vyos-documentation make livehtml

であれば、pdf も作れるのでは?と latexpdf を試してみたところできたので書いておく。

git clone https://github.com/vyos/vyos-documentation.git
cd vyos-documentation
docker run --rm -it -v "$(pwd)":/vyos -w /vyos/docs -e GOSU_UID=$(id -u) -e GOSU_GID=$(id -g) vyos/vyos-documentation make latexpdf

.... (文字がめっちゃいっぱい流れる)
[1]
Chapter 1.
[2]
Chapter 2.
! Missing number, treated as zero.
<to be read again>
                   *
l.292 \begin{footnote}[*]
                         \sphinxAtStartFootnote
? run 👈 run⏎ を入力
.... (文字がものすごい勢いで流れる)
Latexmk: References changed.
Latexmk: References changed.
Latexmk: Log file says output to 'VyOS.pdf'	👈 pdf ファイルができた?
Latexmk: Summary of warnings from last run of *latex:
  =====Latex reported missing or unavailable character(s).
=====See log file for details.
Latexmk: Errors, so I did not complete making targets
Collected error summary (may duplicate other messages):
  pdflatex: Command for 'pdflatex' gave return code 1
      Refer to 'VyOS.log' for details
Latexmk: Use the -f option to force complete processing,
 unless error was exceeding maximum runs, or warnings treated as errors.
make[1]: *** [Makefile:29: VyOS.pdf] Error 12	👈 エラーっぽいな
make[1]: Leaving directory '/vyos/docs/_build/latex'
make: *** [Makefile:24: latexpdf] Error 2	👈 エラーで終わったなぁ
abc123@CoreDNS-deb:~/vyos-documentation$

エラーで終わったように見えるが ./docs/_build/latex/VyOS.pdf に pdf ファイルができている。
NotebookLM とかに突っ込むと最新のドキュメントを参照して教えてくれるんじゃないかな。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?