# 1.通过 macvlan 添加一块虚拟网口macvlan_host来实现容器与宿主机互通
ip link add link ens192 macvlan_host type macvlan mode bridge
# 1.1 为该接口分配ip,实际上可以不用分配
ip addr add 192.168.1.14 dev macvlan_host
# 1.2 启用网卡
ip link set macvlan_host up
# 2.检查macvlan_host 网口,确保是 UP 状态
ip link show | grep macvlan_host
# 3. 添加宿主机到容器的专有路由(在宿主机上执行)
ip route add 192.168.1.13 dev macvlan_host
ip route add 192.168.1.12 dev macvlan_host
# 4. 加入开机启动
vim /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local