docker中macvlan网络模式

群晖docker网卡原来为macvlan模式,虚拟机获取与群晖在同一网段IP;
聚合后,docker虚拟机不能正常开启,删除原先macvlan网络,重新绑定至bond网卡;

root@jing:~# ip addr //查看当前网络

1: lo:  mtu 65536 qdisc noqueue state UNKNOWN

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

      valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host

      valid_lft forever preferred_lft forever

2: sit0:  mtu 1480 qdisc noop state DOWN

    link/sit 0.0.0.0 brd 0.0.0.0

3: eth0:  mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000

    link/ether 00:11:32:11:22:33 brd ff:ff:ff:ff:ff:ff

    inet6 fe80::211:32ff:fe11:2233/64 scope link

      valid_lft forever preferred_lft forever

4: eth1:  mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000

    link/ether 10:90:27:e8:48:0e brd ff:ff:ff:ff:ff:ff

    inet6 fe80::1290:27ff:fee8:480e/64 scope link

      valid_lft forever preferred_lft forever

5: ovs-system:  mtu 1500 qdisc noop state DOWN

    link/ether 02:d2:66:12:b5:06 brd ff:ff:ff:ff:ff:ff

7: ovs_bond0:  mtu 1500 qdisc noqueue state UNKNOWN

    link/ether 00:11:32:11:22:33 brd ff:ff:ff:ff:ff:ff

    inet 192.168.172.50/24 brd 192.168.172.255 scope global ovs_bond0    //当前使用中的网卡

      valid_lft forever preferred_lft forever

    inet6 fe80::211:32ff:fe11:2233/64 scope link

      valid_lft forever preferred_lft forever

8: docker0:  mtu 1500 qdisc noqueue state UP

    link/ether 02:42:c5:aa:0f:ec brd ff:ff:ff:ff:ff:ff

    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0

      valid_lft forever preferred_lft forever

    inet6 fe80::42:c5ff:feaa:fec/64 scope link

      valid_lft forever preferred_lft forever

14: docker3819069:  mtu 1500 qdisc noqueue master docker0 state UP

    link/ether ca:83:aa:71:69:22 brd ff:ff:ff:ff:ff:ff

    inet6 fe80::c883:aaff:fe71:6922/64 scope link

      valid_lft forever preferred_lft forever

50: dockera9b8a1d:  mtu 1500 qdisc noqueue master docker0 state UP

    link/ether 9a:28:44:43:72:91 brd ff:ff:ff:ff:ff:ff

    inet6 fe80::9828:44ff:fe43:7291/64 scope link

      valid_lft forever preferred_lft forever

root@jing:~# docker network ls    //查看当前docker网络

NETWORK ID    NAME          DRIVER    SCOPE

cffd4206c88f  bridge        bridge    local

2ce7d2cad799  bridge-host  macvlan  local

956ab79b82d3  host          host      local

c70c0ac403d3  none          null      local

root@jing:~# docker network rm bridge-host    //删除名为[biadre-host]的网络

bridge-host

root@jing:~# docker network ls

NETWORK ID    NAME      DRIVER    SCOPE

cffd4206c88f  bridge    bridge    local

956ab79b82d3  host      host      local

c70c0ac403d3  none      null      local

root@jing:~# docker network create -d macvlan --subnet=192.168.172.0/24 --gateway=192.168.172.254 -o parent=ovs_bond0 bridge-host

root@jing:~# docker network ls

NETWORK ID    NAME          DRIVER    SCOPE

cffd4206c88f  bridge        bridge    local

cd439ccd151c  bridge-host  macvlan  local    //创建完成

956ab79b82d3  host          host      local

c70c0ac403d3  none          null      local

docker network create -d macvlan --subnet=192.168.172.0/24 --gateway=192.168.172.254 -o parent=ovs_bond0 bridge-host

命令解释:

docker network create -d macvlan #指定创建的网络类型是macvlan
--subnet=192.168.172.0/24 #macvlan的ipv4网段,这里写你的内网网段即可。
--gateway=192.168.172.254 #macvlan的ipv4网关,这里写您需要容器走的网关。
--ipv6 #启用ipv6支持
--subnet=2408::/60 #macvlan的ipv6前缀
--gateway=2408::1 #macvlan的ipv6网关
-o parent=ovs_eth0 #桥接网络走的是ovs_bond0接口,自行更改。
name #macvlan网络的名称

你可能感兴趣的:(docker中macvlan网络模式)