6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VXLAN勉強メモ

6
Last updated at Posted at 2026-03-06

おことわり

ただの個人的なVXLAN勉強メモです。EVPNなどは使わず、シンプルなVXLANのみです。

VXLANとは?

VXLAN(Virtual eXtensible LAN)は、L3ネットワーク上にL2ネットワークをオーバーレイとして構築するためのトンネリング技術である。

従来のVLANは最大4095個までという制限があり、大規模なデータセンター環境ではテナント分離数が不足するという問題があった。またL2ネットワークの拡張はSTPに依存するため、冗長リンクがブロックされるなど効率が悪いという問題もある。

VXLANではL2フレームをUDPでカプセル化してL3ネットワーク上を転送することで、これらの問題を解決する。

VXLANではVLANの代わりにVNI(VXLAN Network Identifier)を使用し、最大約1600万のネットワークを識別できる。

加えて、地理的に遠いデータセンターなどにVMを移動させたとき、シームレスに通信を継続できるようになるなどのメリットもある。

ヘッダフォーマット

+-------------------+-----------+--------+-------------+-------------------+-----------+--------+
| outer ethernet    | outer ip  | udp    | vxlan       | inner ethernet    | inner ip  | data   |
| header            | header    | header | header      | header            | header    |        |
+-------------------+-----------+--------+-------------+-------------------+-----------+--------+

オリジナルイーサネットヘッダをVXLANでカプセル化する。
UDP/4789を使用する

設定してみる

containerlabを使用して設定してみる。Arista cEOSを使用する。

準備

image.png
トポロジは画像の通りで、必要なファイルは以下の通り。

vxlan-tutorial.clab.yml
./vxlan-tutorial.clab.yml
name: vxlan-tutorial

mgmt:
  ipv4-subnet: 172.20.20.0/24

topology:
  kinds:
    ceos:
      image: ceos:4.35.2F
    linux:
      image: ghcr.io/hellt/network-multitool
  nodes:
    spine01:
      kind: ceos
      mgmt-ipv4: 172.20.20.10
      startup-config: configs/spine01.cfg
    spine02:
      kind: ceos
      mgmt-ipv4: 172.20.20.11
      startup-config: configs/spine02.cfg
    leaf01:
      kind: ceos
      mgmt-ipv4: 172.20.20.20
      startup-config: configs/leaf01.cfg
    leaf02:
      kind: ceos
      mgmt-ipv4: 172.20.20.21
      startup-config: configs/leaf02.cfg
    leaf03:
      kind: ceos
      mgmt-ipv4: 172.20.20.22
      startup-config: configs/leaf03.cfg
    leaf04:
      kind: ceos
      mgmt-ipv4: 172.20.20.23
      startup-config: configs/leaf04.cfg
    host01:
      kind: linux
      mgmt-ipv4: 172.20.20.30
      exec:
        - ip link set eth1 up
        - ip addr add 192.168.1.1/24 dev eth1
        - ip route add 192.168.2.0/24 via 192.168.1.254 dev eth1
    host02:
      kind: linux
      mgmt-ipv4: 172.20.20.31
      exec:
        - ip link set eth1 up
        - ip addr add 192.168.2.1/24 dev eth1
        - ip route add 192.168.1.0/24 via 192.168.2.254 dev eth1
    host03:
      kind: linux
      mgmt-ipv4: 172.20.20.32
      exec:
        - ip link set eth1 up
        - ip addr add 192.168.1.2/24 dev eth1
        - ip route add 192.168.2.0/24 via 192.168.1.254 dev eth1
    host04:
      kind: linux
      mgmt-ipv4: 172.20.20.33
      exec:
        - ip link set eth1 up
        - ip addr add 192.168.2.2/24 dev eth1
        - ip route add 192.168.1.0/24 via 192.168.2.254 dev eth1

  links:
    - endpoints: ["spine01:eth1", "leaf01:eth63"]
    - endpoints: ["spine01:eth2", "leaf02:eth63"]
    - endpoints: ["spine01:eth3", "leaf03:eth63"]
    - endpoints: ["spine01:eth4", "leaf04:eth63"]
    - endpoints: ["spine02:eth1", "leaf01:eth64"]
    - endpoints: ["spine02:eth2", "leaf02:eth64"]
    - endpoints: ["spine02:eth3", "leaf03:eth64"]
    - endpoints: ["spine02:eth4", "leaf04:eth64"]
    - endpoints: ["leaf01:eth1", "host01:eth1"]
    - endpoints: ["leaf02:eth1", "host02:eth1"]
    - endpoints: ["leaf03:eth1", "host03:eth1"]
    - endpoints: ["leaf04:eth1", "host04:eth1"]
./configs/spine01.cfg
./configs/spine01.cfg
!
no aaa root
!
username admin privilege 15 role network-admin secret sha512 .X4tjh.WMWmUjgVfN5cEhPmnEsqtY.A/L20
!
management api http-commands
   no shutdown
!
no service interface inactive port-id allocation disabled
!
service routing protocols model multi-agent
!
hostname spine01
!
spanning-tree mode mstp
!
system l1
   unsupported speed action error
   unsupported error-correction action error
!
management api gnmi
   transport grpc default
!
management api netconf
   transport ssh default
!
interface Ethernet1
   no switchport
   ip address 10.0.0.0/31
!
interface Ethernet2
   no switchport
   ip address 10.0.0.2/31
!
interface Ethernet3
   no switchport
   ip address 10.0.0.4/31
!
interface Ethernet4
   no switchport
   ip address 10.0.0.6/31
!
interface Loopback0
   ip address 192.168.255.1/32
!
interface Management0
   ip address 172.20.20.10/24
!
ip routing
!
ip route 0.0.0.0/0 172.20.20.1
!
./configs/spine02.cfg
./configs/spine02.cfg
!
no aaa root
!
username admin privilege 15 role network-admin secret sha512 /Rj3RW.816T0ai6y5C/5SWCGkgjFRcuUpHWtqYKXICREU/ax5DMkRHYF4y/y.WjKqCNwOp82prUeJv.p.
!
management api http-commands
   no shutdown
!
no service interface inactive port-id allocation disabled
!
service routing protocols model multi-agent
!
hostname spine02
!
spanning-tree mode mstp
!
system l1
   unsupported speed action error
   unsupported error-correction action error
!
management api gnmi
   transport grpc default
!
management api netconf
   transport ssh default
!
interface Ethernet1
   no switchport
   ip address 10.0.1.0/31
!
interface Ethernet2
   no switchport
   ip address 10.0.1.2/31
!
interface Ethernet3
   no switchport
   ip address 10.0.1.4/31
!
interface Ethernet4
   no switchport
   ip address 10.0.1.6/31
!
interface Loopback0
   ip address 192.168.255.2/32
!
interface Management0
   ip address 172.20.20.11/24
!
ip routing
!
ip route 0.0.0.0/0 172.20.20.1
!
./configs/leaf01.cfg
./configs/leaf01.cfg
!
no aaa root
!
username admin privilege 15 role network-admin secret sha512 .llPNUQ.TzEKqr3yHyyvTIeg9UA0jInsZxwSAXcE3Vlx6h7N4yfIeET.pQtXDh5jbTms1V2McK5AJwGHAa7bLxFs0NR/O0
!
management api http-commands
   no shutdown
!
no service interface inactive port-id allocation disabled
!
service routing protocols model multi-agent
!
hostname leaf01
!
spanning-tree mode mstp
!
system l1
   unsupported speed action error
   unsupported error-correction action error
!
management api gnmi
   transport grpc default
!
management api netconf
   transport ssh default
!
interface Ethernet1
!
interface Ethernet63
   no switchport
   ip address 10.0.0.1/31
!
interface Ethernet64
   no switchport
   ip address 10.0.1.1/31
!
interface Loopback0
   ip address 192.168.255.3/32
!
interface Management0
   ip address 172.20.20.20/24
!
ip routing
!
ip route 0.0.0.0/0 172.20.20.1
!
./configs/leaf02.cfg
./configs/leaf02.cfg
!
no aaa root
!
username admin privilege 15 role network-admin secret sha512 .FiK.UArP7qKDuh4FtSMwolg4nkxqjyl9JpeOskhuH0
!
management api http-commands
   no shutdown
!
no service interface inactive port-id allocation disabled
!
service routing protocols model multi-agent
!
hostname leaf02
!
spanning-tree mode mstp
!
system l1
   unsupported speed action error
   unsupported error-correction action error
!
management api gnmi
   transport grpc default
!
management api netconf
   transport ssh default
!
interface Ethernet1
!
interface Ethernet63
   no switchport
   ip address 10.0.0.3/31
!
interface Ethernet64
   no switchport
   ip address 10.0.1.3/31
!
interface Loopback0
   ip address 192.168.255.4/32
!
interface Management0
   ip address 172.20.20.21/24
!
ip routing
!
ip route 0.0.0.0/0 172.20.20.1
!
./configs/leaf03.cfg
./configs/leaf03.cfg
!
no aaa root
!
username admin privilege 15 role network-admin secret sha512 /ocNqTNQos/fybM6LC4Bms7xtGRL6F5MG3VzhTEo3BuFq7NPKsRueiX3KMbw0
!
management api http-commands
   no shutdown
!
no service interface inactive port-id allocation disabled
!
service routing protocols model multi-agent
!
hostname leaf03
!
spanning-tree mode mstp
!
system l1
   unsupported speed action error
   unsupported error-correction action error
!
management api gnmi
   transport grpc default
!
management api netconf
   transport ssh default
!
interface Ethernet1
!
interface Ethernet63
   no switchport
   ip address 10.0.0.5/31
!
interface Ethernet64
   no switchport
   ip address 10.0.1.5/31
!
interface Loopback0
   ip address 192.168.255.5/32
!
interface Management0
   ip address 172.20.20.22/24
!
ip routing
!
ip route 0.0.0.0/0 172.20.20.1
!
./configs/leaf04.cfg
./configs/leaf04.cfg
!
no aaa root
!
username admin privilege 15 role network-admin secret sha512 /mEuq7p/jRHkf0kH./mHu91tZ1h4POGKOH3ef0Q8cGi2fSY1y7maD.JTj4tTXmdCLNN/YlsBjWCTCVIQNNalp.
!
management api http-commands
   no shutdown
!
no service interface inactive port-id allocation disabled
!
service routing protocols model multi-agent
!
hostname leaf04
!
spanning-tree mode mstp
!
system l1
   unsupported speed action error
   unsupported error-correction action error
!
management api gnmi
   transport grpc default
!
management api netconf
   transport ssh default
!
interface Ethernet1
!
interface Ethernet63
   no switchport
   ip address 10.0.0.7/31
!
interface Ethernet64
   no switchport
   ip address 10.0.1.7/31
!
interface Loopback0
   ip address 192.168.255.6/32
!
interface Management0
   ip address 172.20.20.23/24
!
ip routing
!
ip route 0.0.0.0/0 172.20.20.1
!

デフォルト状態からip routingを有効化、各インターフェースのIPアドレスを設定したのみ。

アンダーレイ設定

VXLANのVTEP間通信はごく普通のIP通信として行われる。アンダーレイを抽象化するために、アンダーレイのいずれかのリンクがダウンしたとしても到達性が完全に失われない限り通信が継続できるようにしたい。そのためにBGPでVTEPとなるループバックインターフェースの経路交換を行う。

ASNは以下の通り。

  • spine01: 65000
  • spine02: 65001
  • leaf01: 65010
  • leaf02: 65011
  • leaf03: 65012
  • leaf04: 65013
spine01
router bgp 65000
   router-id 192.168.255.1
   neighbor 10.0.0.1 remote-as 65010
   neighbor 10.0.0.3 remote-as 65011
   neighbor 10.0.0.5 remote-as 65012
   neighbor 10.0.0.7 remote-as 65013
   network 192.168.255.1/32
spine02
router bgp 65001
   router-id 192.168.255.2
   neighbor 10.0.1.1 remote-as 65010
   neighbor 10.0.1.3 remote-as 65011
   neighbor 10.0.1.5 remote-as 65012
   neighbor 10.0.1.7 remote-as 65013
   network 192.168.255.2/32
leaf01
router bgp 65010
   router-id 192.168.255.3
   neighbor 10.0.0.0 remote-as 65000
   neighbor 10.0.1.0 remote-as 65001
   network 192.168.255.3/32
leaf02
router bgp 65011
   router-id 192.168.255.4
   neighbor 10.0.0.2 remote-as 65000
   neighbor 10.0.1.2 remote-as 65001
   network 192.168.255.4/32
leaf03
router bgp 65012
   router-id 192.168.255.5
   neighbor 10.0.0.4 remote-as 65000
   neighbor 10.0.1.4 remote-as 65001
   network 192.168.255.5/32
leaf04
router bgp 65013
   router-id 192.168.255.6
   neighbor 10.0.0.6 remote-as 65000
   neighbor 10.0.1.6 remote-as 65001
   network 192.168.255.6/32

全スイッチがそれぞれのループバックアドレスを学習しているか確認する。

sh ip route bgp

オーバーレイ設定

各リーフにてVXLANを設定する。必要な項目は以下の2点。

  • VLANの設定
  • VXLANの設定

今回はleaf01, leaf03でvlan100を、leaf02, leaf04でvlan200を設定してみる。

VLAN設定

leaf01

vlan 100
interface Ethernet1
  switchport access vlan 100
interface Vlan100
   ip address 192.168.1.254/24

leaf03

vlan 100
interface Ethernet1
  switchport access vlan 100

これは普通に追加

VXLAN設定

leaf01

interface Vxlan1
   vxlan source-interface Loopback0
   vxlan vlan 100 vni 90100
   vxlan flood vtep 192.168.255.5

interface Vxlan [IF番号]でインターフェースを作成して設定する。
vxlan source-interface [interface名] でVTEPとなるインターフェースを指定する。
vxlan vlan [VLAN ID] vni [VNI] でVNIに紐づけるVLANを設定する。
vxlan flood vtep [VTEP IP] でBUMのフラッディング先となるVTEPを指定する。

leaf03

interface Vxlan1
   vxlan source-interface Loopback0
   vxlan vlan 100 vni 90100
   vxlan flood vtep 192.168.255.3

※leaf02, leaf04は同様なので割愛

疎通確認

SVIへの通信

host01

bash-5.0# ping 192.168.1.254
PING 192.168.1.254 (192.168.1.254) 56(84) bytes of data.
64 bytes from 192.168.1.254: icmp_seq=1 ttl=64 time=1.15 ms
64 bytes from 192.168.1.254: icmp_seq=2 ttl=64 time=1.16 ms

通信可能

host03

bash-5.0# ping 192.168.1.254
PING 192.168.1.254 (192.168.1.254) 56(84) bytes of data.
64 bytes from 192.168.1.254: icmp_seq=1 ttl=64 time=4.30 ms
64 bytes from 192.168.1.254: icmp_seq=2 ttl=64 time=2.08 ms

通信可能

ホスト間通信

host01

bash-5.0# ping 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=3.26 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=3.32 ms

通信可能

host03

bash-5.0# ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=3.42 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=3.03 ms

通信可能

host03における通信フロー

host03 -> leaf03(vlan100) -> vxlan tunnel(vni 90100) -> leaf01(vlan100) -> host01

L2レベルで疎通できている。

leaf01で確認

leaf01#sh vxlan address-table
          Vxlan Mac Address Table
----------------------------------------------------------------------

VLAN  Mac Address     Type      Prt  VTEP             Moves   Last Move
----  -----------     ----      ---  ----             -----   ---------
 100  aac1.ab2c.c1d5  DYNAMIC   Vx1  192.168.255.5    1       0:00:02 ago
Total Remote Mac Addresses for this criterion: 1

VTEP越しにMACアドレスを学習している。

思ったこと

  • 結局VLANと紐づけが必要ならVNIも最大で4095個なのでは?
    ⇒ 1台のleafが全VLANを把握する必要はない。各スイッチが持つVLANはラック内の環境で必要な分だけでいい。全スイッチが知るべきなのはVNIのみ。VLANはラック内のサーバーネットワークをよしなにするためのものであって、VXLANはそれを一段抽象化するもの。
  • BUMトラフィックがVTEPにフラッディングされる。高負荷では?
    ⇒ EVPNと組み合わせれば解決可能(らしい)
  • VLAN SVIが1台のleafにしか存在しないなら、トラフィックが遠回りするのでは?
    ⇒ シンプルなVXLANのみだとそうなってしまう。Distributed Anycast Gatewayというもので回避ができる(らしい)

さいごに

上記の問題点を解決するために、次はEVPNと組み合わせてやってみます。ついでにDistributed Anycast Gatewayも設定してみます。

6
6
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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?