Container Labで構築したFRRでRIPを自動設定

## 目的
container labでFRRを構築する時は、コンテナ起動時に設定自動的に投入する事が出来る。


![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2738475/1acfc402-a8a2-b644-fd83-7a84554649c9.png)

## IP設定
router1
 - eth1: 192.168.1.1
 - eth2: 192.168.3.1

router2
 - eth1: 192.168.1.2
 - eth2: 192.168.2.2

router3
 - eth1: 192.168.3.2
 - eth2: 192.168.2.1

## 構築

### clab.yml

```yml
name: frr01

topology:
  nodes:
    router1:
      kind: linux
      image: frrouting/frr:v7.5.1
      binds:
        - router1/daemons:/etc/frr/daemons
        - router1/frr.conf:/etc/frr/frr.conf
    router2:
      kind: linux
      image: frrouting/frr:v7.5.1
      binds:
        - router2/daemons:/etc/frr/daemons
        - router2/frr.conf:/etc/frr/frr.conf
    router3:
      kind: linux
      image: frrouting/frr:v7.5.1
      binds:
        - router3/daemons:/etc/frr/daemons
        - router3/frr.conf:/etc/frr/frr.conf
    PC1:
      kind: linux
      image: praqma/network-multitool:latest
    PC2:
      kind: linux
      image: praqma/network-multitool:latest
    PC3:
      kind: linux
      image: praqma/network-multitool:latest

  links:
    - endpoints: ["router1:eth1", "router2:eth1"]
    - endpoints: ["router1:eth2", "router3:eth1"]
    - endpoints: ["router2:eth2", "router3:eth2"]
```

## router1/daemons
```conf
zebra=yes
bgpd=no
ospfd=yes
ospf6d=no
ripd=yes
ripngd=no
isisd=no
pimd=no
ldpd=yes
nhrpd=no
eigrpd=no
babeld=no
sharpd=no
staticd=no
pbrd=no
bfdd=no
fabricd=no

vtysh_enable=yes
zebra_options=" -s 90000000 --daemon -A 127.0.0.1"
bgpd_options="   --daemon -A 127.0.0.1"
ospfd_options="  --daemon -A 127.0.0.1"
ospf6d_options=" --daemon -A ::1"
ripd_options="   --daemon -A 127.0.0.1"
ripngd_options=" --daemon -A ::1"
isisd_options="  --daemon -A 127.0.0.1"
pimd_options="  --daemon -A 127.0.0.1"
ldpd_options="  --daemon -A 127.0.0.1"
nhrpd_options="  --daemon -A 127.0.0.1"
eigrpd_options="  --daemon -A 127.0.0.1"
babeld_options="  --daemon -A 127.0.0.1"
sharpd_options="  --daemon -A 127.0.0.1"
staticd_options="  --daemon -A 127.0.0.1"
pbrd_options="  --daemon -A 127.0.0.1"
bfdd_options="  --daemon -A 127.0.0.1"
fabricd_options="  --daemon -A 127.0.0.1"
```


## router1/frr.conf
```conf
frr version 7.5.1_git
frr defaults traditional
hostname router1
no ipv6 forwarding
!
interface eth1
 ip address 192.168.1.1/24
!
interface eth2
 ip address 192.168.3.1/24
!
router rip
 network 192.168.1.0/24
 network 192.168.3.0/24
!
line vty
!
```

## router2/frr.conf
```conf
frr version 7.5.1_git
frr defaults traditional
hostname router2
no ipv6 forwarding
!
interface eth1
 ip address 192.168.1.2/24
!
interface eth2
 ip address 192.168.2.2/24
!
router rip
 network 192.168.1.0/24
 network 192.168.2.0/24
!
line vty
!
```

## router3/frr.conf
```conf
frr version 7.5.1_git
frr defaults traditional
hostname router3
no ipv6 forwarding
!
interface eth1
 ip address 192.168.3.2/24
!
interface eth2
 ip address 192.168.2.1/24
!
router rip
 network 192.168.3.0/24
 network 192.168.2.0/24
!
line vty
!
```

## 確認

router3にて確認
```bash
bash-5.1# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: seq=0 ttl=64 time=0.333 ms
64 bytes from 192.168.1.1: seq=1 ttl=64 time=0.314 ms
^C
--- 192.168.1.1 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.314/0.323/0.333 ms
bash-5.1# ping 192.168.1.2
PING 192.168.1.2 (192.168.1.2): 56 data bytes
64 bytes from 192.168.1.2: seq=0 ttl=63 time=0.435 ms
^C
--- 192.168.1.2 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.435/0.435/0.435 ms
bash-5.1#
bash-5.1#
bash-5.1# vtysh
% Can't open configuration file /etc/frr/vtysh.conf due to 'No such file or directory'.

Hello, this is FRRouting (version 7.5.1_git).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

router3#
router3# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup

K>* 0.0.0.0/0 [0/0] via 172.20.20.1, eth0, 00:02:38
C>* 172.20.20.0/24 is directly connected, eth0, 00:02:38
R>* 192.168.1.0/24 [120/2] via 192.168.3.1, eth1, weight 1, 00:02:37
C>* 192.168.2.0/24 is directly connected, eth2, 00:02:38
C>* 192.168.3.0/24 is directly connected, eth1, 00:02:38
```