bgp+vxlan组网
明白了,你希望完整实现三台主机,VXLAN 隧道,同时 iBGP 和 eBGP 分别在不同 AS的组网方案。下面我给你整理成清晰、可直接部署的方案。
一、iBGP(同 AS 内 VXLAN 通告)
1️⃣ 拓扑
| 主机 | 物理 IP | Router ID | AS号 |
|---|---|---|---|
| Linux-A | 192.168.1.1 | 10.0.0.1 | 65001 |
| Linux-B | 192.168.1.2 | 10.0.0.2 | 65001 |
| Linux-C | 192.168.1.3 | 10.0.0.3 | 65001 |
VXLAN 隧道(iBGP 内部网络):
| VXLAN | VNI | 源 | 目的 | 子网 |
|---|---|---|---|---|
| vxlan-A-B | 100 | 192.168.1.1 | 192.168.1.2 | 10.10.1.0/24 |
| vxlan-A-C | 101 | 192.168.1.1 | 192.168.1.3 | 10.10.2.0/24 |
| vxlan-B-C | 102 | 192.168.1.2 | 192.168.1.3 | 10.10.3.0/24 |
2️⃣ Linux 配置(VXLAN & IP)
Linux-A:
ip addr add 192.168.1.1/24 dev eth0
ip link set eth0 up
# VXLAN 隧道
ip link add vxlan-A-B type vxlan id 100 dev eth0 remote 192.168.1.2 dstport 4789
ip addr add 10.10.1.1/24 dev vxlan-A-B
ip link set vxlan-A-B up
ip link add vxlan-A-C type vxlan id 101 dev eth0 remote 192.168.1.3 dstport 4789
ip addr add 10.10.2.1/24 dev vxlan-A-C
ip link set vxlan-A-C up
Linux-B:
ip addr add 192.168.1.2/24 dev eth0
ip link set eth0 up
ip link add vxlan-B-A type vxlan id 100 dev eth0 remote 192.168.1.1 dstport 4789
ip addr add 10.10.1.2/24 dev vxlan-B-A
ip link set vxlan-B-A up
ip link add vxlan-B-C type vxlan id 102 dev eth0 remote 192.168.1.3 dstport 4789
ip addr add 10.10.3.2/24 dev vxlan-B-C
ip link set vxlan-B-C up
Linux-C:
ip addr add 192.168.1.3/24 dev eth0
ip link set eth0 up
ip link add vxlan-C-A type vxlan id 101 dev eth0 remote 192.168.1.1 dstport 4789
ip addr add 10.10.2.3/24 dev vxlan-C-A
ip link set vxlan-C-A up
ip link add vxlan-C-B type vxlan id 102 dev eth0 remote 192.168.1.2 dstport 4789
ip addr add 10.10.3.3/24 dev vxlan-C-B
ip link set vxlan-C-B up
3️⃣ BIRD 配置(iBGP)
Linux-A (/etc/bird/bird.conf):
router id 10.0.0.1;
protocol kernel {
persist;
scan time 20;
import all;
export all;
}
protocol device { scan time 10; }
protocol bgp iBGP-B {
local as 65001;
neighbor 10.10.1.2 as 65001;
source address 10.10.1.1;
import all;
export all;
}
protocol bgp iBGP-C {
local as 65001;
neighbor 10.10.2.3 as 65001;
source address 10.10.2.1;
import all;
export all;
}
Linux-B 和 Linux-C 配置类似,注意 router ID 和 VXLAN VTEP IP 以及 neighbor IP。
二、eBGP(不同 AS VXLAN 通告)
1️⃣ 拓扑
| 主机 | 物理 IP | Router ID | AS号 |
|---|---|---|---|
| Linux-A | 192.168.2.1 | 20.0.0.1 | 65001 |
| Linux-B | 192.168.2.2 | 20.0.0.2 | 65002 |
| Linux-C | 192.168.3.1 | 30.0.0.1 | 65003 |
VXLAN 隧道(跨 AS):
| VXLAN | VNI | 源 | 目的 | 子网 |
|---|---|---|---|---|
| vxlan-A-C | 200 | 192.168.2.1 | 192.168.3.1 | 20.20.1.0/24 |
| vxlan-B-C | 201 | 192.168.2.2 | 192.168.3.1 | 20.20.2.0/24 |
2️⃣ Linux 配置(VXLAN & IP)
Linux-A:
ip addr add 192.168.2.1/24 dev eth0
ip link set eth0 up
ip link add vxlan-A-C type vxlan id 200 dev eth0 remote 192.168.3.1 dstport 4789
ip addr add 20.20.1.1/24 dev vxlan-A-C
ip link set vxlan-A-C up
Linux-B:
ip addr add 192.168.2.2/24 dev eth0
ip link set eth0 up
ip link add vxlan-B-C type vxlan id 201 dev eth0 remote 192.168.3.1 dstport 4789
ip addr add 20.20.2.2/24 dev vxlan-B-C
ip link set vxlan-B-C up
Linux-C:
ip addr add 192.168.3.1/24 dev eth0
ip link set eth0 up
ip link add vxlan-C-A type vxlan id 200 dev eth0 remote 192.168.2.1 dstport 4789
ip addr add 20.20.1.3/24 dev vxlan-C-A
ip link set vxlan-C-A up
ip link add vxlan-C-B type vxlan id 201 dev eth0 remote 192.168.2.2 dstport 4789
ip addr add 20.20.2.3/24 dev vxlan-C-B
ip link set vxlan-C-B up
3️⃣ BIRD 配置(eBGP)
Linux-A:
router id 20.0.0.1;
protocol kernel {
persist;
scan time 20;
import all;
export all;
}
protocol device { scan time 10; }
protocol bgp eBGP-C {
local as 65001;
neighbor 20.20.1.3 as 65003;
source address 20.20.1.1;
import all;
export all;
}
Linux-B:
router id 20.0.0.2;
protocol kernel { persist; scan time 20; import all; export all; }
protocol device { scan time 10; }
protocol bgp eBGP-C {
local as 65002;
neighbor 20.20.2.3 as 65003;
source address 20.20.2.2;
import all;
export all;
}
Linux-C:
router id 30.0.0.1;
protocol kernel { persist; scan time 20; import all; export all; }
protocol device { scan time 10; }
protocol bgp eBGP-A {
local as 65003;
neighbor 20.20.1.1 as 65001;
source address 20.20.1.3;
import all;
export all;
}
protocol bgp eBGP-B {
local as 65003;
neighbor 20.20.2.2 as 65002;
source address 20.20.2.3;
import all;
export all;
}
✅ 特点总结
-
iBGP:三台机器在同 AS 内,VXLAN 直连,互通内部网络。
-
eBGP:三台机器分别属于不同 AS(65001、65002、65003),通过 VXLAN 建立跨 AS 通道。
-
VXLAN VNI 可随意设定,dstport 默认 4789。
-
VXLAN 替代 IPIP 隧道,更适合二层/多播和 Overlay 网络场景。
-
iBGP 和 eBGP 都支持三台互通,每条 VXLAN 对应一个 neighbor。
浙公网安备 33010602011771号