我曾经发布过类似的问题:https://stackoverflow.com/questions/27873819/customising-docker-network-doesnt-work#
为了简化问题,让我摆脱docker。
这是网络模型:
| CentOS
gateway --|-- enp0s9----br0----A---B
10.0.0.1 | 10.0.1.100
CentOS 是一个 VM,enp0s9
是 VM 的 NIC。br0
是一个 linux 桥,A
是一个 veth 接口,B
是A
的对等体。
我使用以下命令对它们进行配置:
brctl addbr br0
brctl stp br0 off
brctl addif enp0s9
ip link add A type veth peer name B
brctl addif br0 A
ip link set dev A up
ip addr add 10.0.1.100/24 dev B
ip link set dev B up
经过此配置后:
[root@localhost ~]# ip link list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 08:00:27:22:dd:2e brd ff:ff:ff:ff:ff:ff
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 08:00:27:79:04:3a brd ff:ff:ff:ff:ff:ff
4: enp0s9: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000
link/ether 08:00:27:38:f0:e1 brd ff:ff:ff:ff:ff:ff
5: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT
link/ether 08:00:27:38:f0:e1 brd ff:ff:ff:ff:ff:ff
6: B: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 8e:66:81:1c:ca:cf brd ff:ff:ff:ff:ff:ff
7: A: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT qlen 1000
link/ether 7a:f8:de:9d:b3:33 brd ff:ff:ff:ff:ff:ff
但是当我使用 tcpdump 从 CentOS ping 网关时,我可以看到网关已听到 ARP 请求并回复了 ARP 回复。但是 enp0s9 只听到 ARP 请求,没有听到 ARP 回复。
在网关上:
22:54:15.386328 ARP, Request who-has 10.0.1.1 tell 10.0.1.100, length 46
22:54:15.386350 ARP, Reply 10.0.1.1 is-at 0a:00:27:00:00:01 (oui Unknown), length 28
在 enp0s9 上:
09:54:58.748210 ARP, Request who-has 10.0.1.1 tell localhost.localdomain, length 28
我的配置有什么问题?如何让网关和 B 互相 ping 通?
在此配置中,enp0s9
充当 L2 集线器,是否需要对其进行任何特殊配置?
答案1
目前 Docker 网络并不是很容易实现。我建议尝试编织。