docker macvlan虚拟化网络与宿主机通信问题解决
环境说明:
宿主机: 10.8.59.200
容器:10.8.59.38
虚拟 IP(做路由实现通信):10.8.59.37
宿主机物理网卡名称:ens33
# 添加一个虚拟接口桥接到物理网卡
ip link add macvlan-proxy link ens33 type macvlan mode bridge
# 给虚拟接口配置ip
ip addr add 10.8.59.37/24 dev macvlan-proxy
# 启用虚拟接口
ip link set macvlan-proxy up
# 添加到容器网络的静态路由规则
ip route add 10.8.59.0/24 dev macvlan-proxy