docker: FRR OSPF

各拠点をOpenVPNで接続したので、ルーティングの設定を行う。FRRを導入しているので、動的ルーティング(OSPF)によるルーティング設定を行ってみる。※異なる環境で取得したログを次図の環境向けに書き直して記載しているためログは誤っている可能性あり

ospf network image

VPSからは次のネットワークをOSPFで配布する。

  • dockerのネットワーク:172.16.0.0/24
frr_A # show run
~~~省略~~~
interface tun01
 ip ospf cost 10000
 ip ospf network non-broadcast
 ip ospf priority 255
!
router ospf
 ospf router-id 1.1.1.1
 redistribute connected route-map OSPF-RED-CON
 passive-interface default
 no passive-interface tun01
 network 10.8.1.0/24 area 0
 neighbor 10.8.1.2
 neighbor 10.8.1.3
!
ip prefix-list OSPF-RED-CON-LIST seq 100 permit 172.16.0.0/16 le 24
!
route-map OSPF-RED-CON permit 10
 match ip address prefix-list OSPF-RED-CON-LIST
 set tag 11110
!
line vty
!
end

Raspberry piのFRRにもOSPFの設定を行う。

frr_B# show run
~~~省略~~~
interface tun11
 ip ospf cost 10000
 ip ospf network non-broadcast
 ip ospf priority 0
!
router ospf
 ospf router-id 2.2.2.3
 redistribute connected route-map OSPF-RED-CON
 passive-interface default
 no passive-interface eth0
 no passive-interface tun11
 network 10.8.1.0/24 area 0
 network 192.168.16.0/24 area 0
 neighbor 10.8.1.1
!
ip prefix-list OSPF-RED-CON-LIST seq 100 permit 192.168.16.0/20 le 32
ip prefix-list OSPF-RED-CON-LIST seq 110 permit 10.8.1.0/24 le 24
!
route-map OSPF-RED-CON permit 10
 match ip address prefix-list OSPF-RED-CON-LIST
 set tag 22230
!
line vty
!
end

ciscoルータ(C841M)にもOSPF設定を行う。

router_B#show run
~~~省略~~~
version 15.5
~~~省略~~~
!
router ospf 1
 router-id 2.2.2.2
 redistribute connected subnets route-map OSPF-RED-CON
 redistribute static subnets route-map OSPF-RED-STATIC
 passive-interface default
 no passive-interface GigabitEthernet0/4
 network 192.168.16.0 0.0.0.255 area 0
!
ip prefix-list OSPF-RED-CON-LIST seq 100 permit 192.168.16.0/20 le 32
!
ip prefix-list OSPF-RED-STATIC-LIST seq 100 permit 192.168.16.0/20 le 32
!
route-map OSPF-RED-CON permit 10
 match ip address prefix-list OSPF-RED-CON-LIST
 set tag 22220
!
route-map OSPF-RED-STATIC permit 10
 match ip address prefix-list OSPF-RED-STATIC-LIST
 set tag 22221
!

VPS側のOSPF状態を確認する。

frr_A # show ip ospf nei

Neighbor ID   Pri State           Dead Time Address         Interface             RXmtL RqstL DBsmL
2.2.2.3         0 Full/DROther      35.987s 10.8.1.2        tun01:10.8.1.1            0     0     0
3.3.3.3         0 Full/DROther      39.407s 10.8.1.3        tun01:10.8.1.1            0     0     0

frr_A # show ip ospf route
============ OSPF network routing table ============
N    10.8.1.0/24           [10000] area: 0.0.0.0
                           directly attached to tun01
N    192.168.16.0/24       [10100] area: 0.0.0.0
                           via 10.8.1.2, tun01
N    192.168.32.0/24       [10100] area: 0.0.0.0
                           via 10.8.1.3, tun01

~~~省略~~~

============ OSPF external routing table ===========
N E2 192.168.17.0/24       [10100/20] tag: 22220
                           via 10.8.1.2, tun01
N E2 192.168.33.0/24       [10100/20] tag: 33320
                           via 10.8.1.3, tun01

raspberry piのOSPF状態を確認する。

frr_B# show ip ospf nei

Neighbor ID   Pri State           Dead Time Address         Interface             RXmtL RqstL DBsmL
2.2.2.2         1 Full/Backup       35.693s 192.168.16.2    eth0:192.168.16.194       0     0     0
1.1.1.1       255 Full/DR           35.341s 10.8.1.1        tun11:10.8.1.2            0     0     0

frr_B# show ip ospf route
============ OSPF network routing table ============
N    10.8.1.0/24           [10000] area: 0.0.0.0
                           directly attached to tun11
N    192.168.16.0/24       [100] area: 0.0.0.0
                           directly attached to eth0
N    192.168.32.0/24       [10100] area: 0.0.0.0
                           via 10.8.1.3, tun11

~~~省略~~~

============ OSPF external routing table ===========
N E2 172.16.0.0/24         [10000/20] tag: 11110
                           via 10.8.1.1, tun11
N E2 192.168.17.0/24       [100/20] tag: 22220
                           via 192.168.16.2, eth0
N E2 192.168.33.0/24       [10100/20] tag: 33320
                           via 10.8.1.3, tun11

ciscoルータ(C841M)のOSPF状態を確認する。

router_B#show ip ospf nei

Neighbor ID   Pri State           Dead Time Address         Interface
2.2.2.3         1 FULL/DR         00:00:34  192.168.16.194  GigabitEthernet0/4

※ルーティングは省略

これでVPSやVPNの冗長化を行った際に動的にルーティングを設定が可能となり、ネットワーク管理が楽になるはず。が、流行り?のBGPで構築するのも面白いだろうということで、次はeBGPでの構築で遊んでみたい。