VyOS Spanning-Tree Vlan/Priority on GNS3

前回に引き続きL2機能の検証記事です。今回はvlanとpriorityを設定してみたいと思います。構成は前回の記事と同じです。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/2335933/b2ce0488-75bf-3d3c-b41a-3dfc3dca617f.png)

## 1. 設定変更
まずは1号機から

```bash
conf
set interfaces bridge br00 enable-vlan 
set interfaces bridge br00 priority 4096
set interfaces bridge br00 member interface eth0 allowed-vlan 10
set interfaces bridge br00 member interface eth1 allowed-vlan 10
set interfaces bridge br00 vif 10 address 10.0.10.254/24
commit
save
```

続いて2号機

```bash
conf
set interfaces bridge br00 enable-vlan 
set interfaces bridge br00 priority 12288
set interfaces bridge br00 member interface eth0 allowed-vlan 10
set interfaces bridge br00 member interface eth1 allowed-vlan 10
set interfaces bridge br00 vif 10 address 10.0.10.253/24
commit
save
```

最後に3号機

```bash
conf
set interfaces bridge br00 enable-vlan 
set interfaces bridge br00 priority 8192
set interfaces bridge br00 member interface eth0 allowed-vlan 10
set interfaces bridge br00 member interface eth1 allowed-vlan 10
set interfaces bridge br00 vif 10 address 10.0.10.252/24
commit
save
```

# 2. 動作確認
1号機からステータスを確認します。

```bash
vyos@vyos:~$ show bridge br00 spanning-tree
br00
 bridge id              1000.0c5179790000
 designated root        1000.0c5179790000
 root port                 0                    path cost                  0
 max age                  20.00                 bridge max age            20.00
 hello time                2.00                 bridge hello time          2.00
 forward delay            14.00                 bridge forward delay      14.00
 ageing time             300.00
 hello timer               0.59                 tcn timer                  0.00
 topology change timer     0.00                 gc timer                 254.49
 flags

eth0 (1)
 port id                8001                    state                forwarding
 designated root        1000.0c5179790000       path cost                100
 designated bridge      1000.0c5179790000       message age timer          0.00
 designated port        8001                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

eth1 (2)
 port id                8002                    state                forwarding
 designated root        1000.0c5179790000       path cost                100
 designated bridge      1000.0c5179790000       message age timer          0.00
 designated port        8002                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

vyos@vyos:~$ 
vyos@vyos:~$ ping 10.0.10.253
PING 10.0.10.253 (10.0.10.253) 56(84) bytes of data.
64 bytes from 10.0.10.253: icmp_seq=1 ttl=64 time=6.45 ms
64 bytes from 10.0.10.253: icmp_seq=2 ttl=64 time=1.07 ms
64 bytes from 10.0.10.253: icmp_seq=3 ttl=64 time=0.657 ms
64 bytes from 10.0.10.253: icmp_seq=4 ttl=64 time=0.936 ms
^C
--- 10.0.10.253 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 9ms
rtt min/avg/max/mdev = 0.657/2.276/6.446/2.412 ms
vyos@vyos:~$ ping 10.0.10.252
PING 10.0.10.252 (10.0.10.252) 56(84) bytes of data.
64 bytes from 10.0.10.252: icmp_seq=1 ttl=64 time=0.874 ms
64 bytes from 10.0.10.252: icmp_seq=2 ttl=64 time=0.878 ms
64 bytes from 10.0.10.252: icmp_seq=3 ttl=64 time=0.892 ms
64 bytes from 10.0.10.252: icmp_seq=4 ttl=64 time=0.880 ms
^C
--- 10.0.10.252 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 10ms
rtt min/avg/max/mdev = 0.874/0.881/0.892/0.006 ms
vyos@vyos:~$
```
ブリッジpriorityを3台の中で一番小さい値を設定していますのでインタフェースステータスは二つともフォワードで2号機、3号機に疎通確認もできる状態です。

では続いて2号機を確認しましょう。おそらくどちらかのインタフェースがblockingになっているはずです。

```bash
vyos@vyos:~$ show bridge br00 spanning-tree
br00
 bridge id              3000.0c001a3e0000
 designated root        1000.0c5179790000
 root port                 1                    path cost                100
 max age                  20.00                 bridge max age            20.00
 hello time                2.00                 bridge hello time          2.00
 forward delay            14.00                 bridge forward delay      14.00
 ageing time             300.00
 hello timer               0.00                 tcn timer                  0.00
 topology change timer     0.00                 gc timer                  33.50
 flags

eth0 (1)
 port id                8001                    state                forwarding
 designated root        1000.0c5179790000       path cost                100
 designated bridge      1000.0c5179790000       message age timer         18.99
 designated port        8001                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

eth1 (2)
 port id                8002                    state                  blocking
 designated root        1000.0c5179790000       path cost                100
 designated bridge      2000.0ce102a70000       message age timer         18.98
 designated port        8002                    forward delay timer        0.00
 designated cost         100                    hold timer                 0.00
 flags

vyos@vyos:~$
```
期待通り、2号機のeth1(3号機向けI/F)がblockingになっていました。最後は3号機

```bash
vyos@vyos:~$ show bridge br00 spanning-tree
br00
 bridge id              2000.0ce102a70000
 designated root        1000.0c5179790000
 root port                 1                    path cost                100
 max age                  20.00                 bridge max age            20.00
 hello time                2.00                 bridge hello time          2.00
 forward delay            14.00                 bridge forward delay      14.00
 ageing time             300.00
 hello timer               0.00                 tcn timer                  0.00
 topology change timer     0.00                 gc timer                  56.44
 flags

eth0 (1)
 port id                8001                    state                forwarding
 designated root        1000.0c5179790000       path cost                100
 designated bridge      1000.0c5179790000       message age timer         19.64
 designated port        8002                    forward delay timer        0.00
 designated cost           0                    hold timer                 0.00
 flags

eth1 (2)
 port id                8002                    state                forwarding
 designated root        1000.0c5179790000       path cost                100
 designated bridge      2000.0ce102a70000       message age timer          0.00
 designated port        8002                    forward delay timer        0.00
 designated cost         100                    hold timer                 0.50
 flags

vyos@vyos:~$
```
両方ともフォワーディングですね。

## 3. その他
次回はブリッジとして設定できる内容について、掘り下げた記事を書きたいと思います。