VyOSでのVRF
VyOSでのVRFは主に2種類あります。
当ページは一般的に広く使用されるVRF-Liteの設定について紹介します。
VRF-Lite
Ciscoでは次のように設定を行いました。
- VRFインスタンスを作成する
- (RDを指定する)
- インタフェースとの紐付けを行う
対して、VyOSでは次のように設定を行います。
- VRFインスタンスを作成する
- インタフェースとの紐付けを行う
このように、RDの指定は不要となっています。
VyOSでのVRF-LiteではRDの指定は不要となっています。(L3VPN VRFでは必要ですが、当ページでは紹介しません。)
他のCiscoとの違いとしては、CiscoではVRFインスタンスを変更したりした場合、紐付けられているインタフェースのIPアドレスなどがリセットされる仕様がありました。
対して、VyOSではそのような仕様はなく、IPアドレスは引き継がれます。
なお、IPv6上でもVRFを使用する場合は、CiscoではマルチプロトコルVRFを使用する必要がありましたが、VyOSではそのような区別はなく、通常のVRFでIPv6の設定も行うことができます。
VRFの設定には次のコマンドを使用します。
| 設定項目 |
コマンド |
| VRFインスタンスを作成する |
set vrf name <インスタンス名> table <テーブル番号> |
| インタフェースとVRFインスタンスを紐付ける |
set interface ethernet <インタフェース名> vrf <インスタンス名> |
このようなコマンドを使用します。
VRFインスタンス名に加えて、テーブル番号を指定します。
複数のVRFインスタンスを作成する場合は、テーブル番号は重複させてはいけません。
なお、テーブル番号は100〜65535までの値で指定する必要があります。
関連サービス
VRFはVRF単体で使用することはあまりなく、他のネットワークサービスと併用することが一般的です。
主に次のようなサービスと併用を行うことが多いです。
それぞれ紹介します。
スタティックルート
特定のVRFインスタンスへスタティックルートを登録するには次のコマンドを使用します。
| 設定項目 |
コマンド |
| 特定のVRFでスタティックルートを登録する |
set vrf name <VRF名> protocols static route <宛先ネットワーク/プレフィックス> <next-hop <ネクストホップのIPアドレス> | interface <インタフェース>> |
ルーティングプロトコル
VRF上では、主にOSPFやBGPを動作させることが多いです。
それぞれ、次のコマンドを使用します。
| 設定項目 |
コマンド |
| 特定のVRFでOSPFを有効にする |
set vrf name <VRF名> protocols ospf <各種設定内容> |
| 特定のVRFでBGPを有効にする |
set vrf name <VRF名> protocols bgp <各種設定内容> |
このようになります。
表中の各種設定内容には、普通のOSPFやBGPで実行していたコマンドなどが入ります。
ページ下部の例題3にて、VRF上でのOSPFの設定例を紹介しています。(BGPの設定は複雑になるため、当ページでは紹介を省略しています。)
なお、OSPFやBGPの設定に関しては次のページにて紹介していますので、未学習の場合は目を通していただけると幸いです。
VyOSでのOSPFに関して、Ciscoと異なり、プロセスIDの指定ができません。
CiscoではVRFとOSPFを併用する場合、各VRFごとにプロセスIDを分けていました。
対してVyOSでは、意図的にプロセスを分けなくても、name <VRF名>の指定により、各VRF上でのOSPFのプロセス(デーモン)が独立して動作することとなります。
DHCPサーバ
VRF上でDHCPサーバを動作させる場合、次のコマンドを使用します。
| 設定項目 |
コマンド |
| 特定のVRFでDHCPサーバの設定を行う |
set vrf name <VRF名> service dhcp-server <各種設定内容> |
このようになります。
表中の各種設定内容には、普通のDHCPサーバの設定で実行していたコマンドなどが入ります。
ページ下部の例題2にて、VRF上でのDHCPサーバの設定例を紹介しています。
なお、DHCPサーバの設定に関しては次のページにて紹介していますので、未学習の場合は目を通していただけると幸いです。
VRFは関連するサービスが多いため、説明も長くなってしまいました。
続いて、設定例などを紹介します。
例題1

コマンド
ルータ1
set vrf name red table 100
set vrf name green table 200
set interfaces ethernet eth1 address 10.0.0.1/24
set interfaces ethernet eth1 vrf red
set interfaces ethernet eth2 address 10.10.0.1/24
set interfaces ethernet eth2 vrf red
set interfaces ethernet eth3 address 10.0.0.1/24
set interfaces ethernet eth3 vrf green
set interfaces ethernet eth4 address 10.10.0.1/24
set interfaces ethernet eth4 vrf green
set vrf name red protocols static route 192.168.10.0/24 next-hop 10.0.0.2
set vrf name red protocols static route 192.168.20.0/24 next-hop 10.10.0.2
set vrf name green protocols static route 192.168.10.0/24 next-hop 10.0.0.2
set vrf name green protocols static route 192.168.20.0/24 next-hop 10.10.0.2
ルータ2
set interfaces ethernet eth1 address 10.0.0.2/24
set interfaces ethernet eth2 address 192.168.10.254/24
set protocols static route 0.0.0.0/0 next-hop 10.0.0.1
ルータ3
set interfaces ethernet eth1 address 10.10.0.2/24
set interfaces ethernet eth2 address 192.168.20.254/24
set protocols static route 0.0.0.0/0 next-hop 10.10.0.1
ルータ4
set interfaces ethernet eth1 address 10.0.0.2/24
set interfaces ethernet eth2 address 192.168.10.254/24
set protocols static route 0.0.0.0/0 next-hop 10.0.0.1
ルータ5
set interfaces ethernet eth1 address 10.10.0.2/24
set interfaces ethernet eth2 address 192.168.20.254/24
set protocols static route 0.0.0.0/0 next-hop 10.10.0.1
解説
ルータ1
-
1つ目のブロックでVRFインスタンスを作成しています。
重複しないインスタンス名とテーブル番号を指定する必要があります。
-
2つ目のブロックでインタフェースの設定をしています。
それぞれ、インタフェースのIPアドレスを設定した後にVRFインスタンスとの紐付けを行っています。
-
3つ目のブロックでスタティックルートの登録を行っています。
set vrf nameコマンドから設定を行うことにより、各VRFで適切にスタティックルートの登録を行う必要があります。
その他のルータ
その他のルータでは、VRFに関する設定は特に不要です。
今回はインタフェースのIPアドレスと、デフォルトルートの設定のみを行いました。
確認
VRFの設定に関して確認するには次のコマンドを使用します。
| 確認内容 |
コマンド |
| VRFの設定を確認する |
run show vrf <VRF名> |
| 特定のVRFインスタンスのテーブルを確認する |
run show ip route vrf <VRF名 | all> |
ルーティングテーブルの確認について、Cisco同様、通常のコマンドを使用してしまうとVRFの経路は表示されません。
そのため、特定のVRFインスタンスへ登録した経路はvrfオプションをつけてのみ確認可能となります。
それぞれルータ1で実行してみます。

run show vrfコマンドでは、VRFが有効かどうかや紐付けられているインタフェースなどを確認することができます。
続いて、各ルーティングテーブルを確認します。

今回はvrf allと指定し、すべてのVRFインスタンスの経路を表示しましたが、特定のインスタンス名に限定することも可能です。
また、もし普通のrun show ip routeコマンドを実行するとこのようになります。

今回はグローバルルーティングテーブルになにも経路や設定をしていないため、経路が1つも表示されません。
例題2
例題1のトポロジを流用します。(問題文のみ変更されています。)

コマンド
ルータ1(追加コマンド)
set vrf name red service dhcp-server shared-network-name RED_LAN10 subnet 192.168.10.0/24 subnet-id 10
set vrf name red service dhcp-server shared-network-name RED_LAN10 subnet 192.168.10.0/24 range RED_LAN10 start 192.168.10.10
set vrf name red service dhcp-server shared-network-name RED_LAN10 subnet 192.168.10.0/24 range RED_LAN10 stop 192.168.10.100
set vrf name red service dhcp-server shared-network-name RED_LAN10 subnet 192.168.10.0/24 lease 86400
set vrf name red service dhcp-server shared-network-name RED_LAN10 subnet 192.168.10.0/24 option default-router 192.168.10.254
set vrf name red service dhcp-server listen-address 10.0.0.1
ルータ2(追加コマンド)
set service dhcp-relay listen-interface eth2
set service dhcp-relay upstream-interface eth1
set service dhcp-relay server 10.0.0.1
解説
ルータ1
DHCPサーバに関する設定を行っています。
vrf name red serviceにDHCPの設定を続けることで、特定のVRFインスタンスに対してのみアドレス配布が行えるようになります。
ルータ2
DHCPリレーエージェントの設定を行っています。
そのため、今回はDHCPサーバで配布されるデフォルトゲートウェイのIPアドレスをルータ2のアドレスにしてあげる必要がありました。
例題3

コマンド
ルータ1
set vrf name red table 100
set vrf name green table 200
set interfaces ethernet eth1 address 10.0.0.1/24
set interfaces ethernet eth1 vrf red
set interfaces ethernet eth2 address 10.10.0.1/24
set interfaces ethernet eth2 vrf red
set interfaces ethernet eth3 address 10.0.0.1/24
set interfaces ethernet eth3 vrf green
set interfaces ethernet eth4 address 10.10.0.1/24
set interfaces ethernet eth4 vrf green
set vrf name red protocols ospf interface eth1 area 0
set vrf name red protocols ospf interface eth1 priority 255
set vrf name red protocols ospf interface eth2 area 0
set vrf name red protocols ospf interface eth2 priority 255
set vrf name green protocols ospf interface eth3 area 0
set vrf name green protocols ospf interface eth3 priority 255
set vrf name green protocols ospf interface eth4 area 0
set vrf name green protocols ospf interface eth4 priority 255
ルータ2
set interfaces ethernet eth1 address 10.0.0.2/24
set interfaces ethernet eth2 address 192.168.10.254/24
set protocols ospf interface eth1 area 0
set protocols ospf interface eth2 area 0
set protocols ospf interface eth2 passive
ルータ3
set interfaces ethernet eth1 address 10.10.0.2/24
set interfaces ethernet eth2 address 192.168.20.254/24
set protocols ospf interface eth1 area 0
set protocols ospf interface eth2 area 0
set protocols ospf interface eth2 passive
ルータ4
set interfaces ethernet eth1 address 10.0.0.2/24
set interfaces ethernet eth2 address 192.168.10.254/24
set protocols ospf interface eth1 area 0
set protocols ospf interface eth2 area 0
set protocols ospf interface eth2 passive
ルータ5
set interfaces ethernet eth1 address 10.10.0.2/24
set interfaces ethernet eth2 address 192.168.20.254/24
set protocols ospf interface eth1 area 0
set protocols ospf interface eth2 area 0
set protocols ospf interface eth2 passive
解説
ルータ1
3つ目のブロックで各VRF上でOSPFの設定を行っています。
set vrf nameコマンドからOSPFの設定を行うことで、各VRFごとにOSPFを動作させることができます。
その他のルータ
その他のルータでは、OSPFを動作させることに加え、内部側インタフェースではパッシブインタフェースとすることで無駄なトラフィックを削減しています。
確認
VRF上のOSPFの確認を行うには次のコマンドを使用します。
| 確認内容 |
コマンド |
| VRF上のOSPFの各種設定内容を確認する |
run show ip ospf vrf <VRF名> <各種確認項目> |
| ルーティングテーブルの確認をする |
run show ip route vrf <VRF名 | all> |
試しに、ルータ1でredのネイバーを確認してみます。

続いて、redのルーティングテーブルも確認してみます。

それぞれ適切に登録・認識されていることが確認できました。
以上となります。
VRFはややこしい技術ではありますが、様々なネットワークで使用できる技術ですので、ぜひ身につけましょう。
お疲れ様でした