一、macvlan 自己是 linux kernel 模塊,其功能是容許在同一個物理網卡上配置多個 MAC 地址,linux
二、即多個 interface,每一個 interface 能夠配置本身的 IP。docker
三、macvlan 本質上是一種網卡虛擬化技術centos
一、主機luoahongbash
[root@luoahong ~]# docker network create --driver macvlan --subnet 10.0.0.0/24 --gateway 10.0.0.254 -o parent=eth0 macvlan_1 ffbecd2f57ce5be49b95fa05f0a4566f02d6a006d9ab664f44857997d6c0605b [root@luoahong ~]# docker network ls NETWORK ID NAME DRIVER SCOPE d766f2526542 bridge bridge local 30b37ec09ff2 host host local ffbecd2f57ce macvlan_1 macvlan local ad2616372f01 mywordpress_default bridge local 03062097926d none null local
二、主機luoahong2wordpress
[root@luoahong2 ~]# docker network create --driver macvlan --subnet 10.0.0.0/24 --gateway 10.0.0.254 -o parent=eth0 macvlan_1 6b0642df662e35293727542fea1b6d524f0f564f8162d21283d668a778a1d63f [root@luoahong2 ~]# docker network ls NETWORK ID NAME DRIVER SCOPE 05d195b7d60b bridge bridge local eb998505004d host host local 6b0642df662e macvlan_1 macvlan local 9bd801b589c5 none null local
一、主機luoahong性能
[root@luoahong ~]# docker run -it --network macvlan_1 --ip=10.0.0.111 busybox:latest /bin/sh / # [root@luoahong ~]# docker run -it --network macvlan_1 --ip=10.0.0.188 busybox:latest /bin/sh
二、主機luoahong2測試
[root@luoahong2 ~]# docker run -it --network macvlan_1 --ip=10.0.0.112 busybox:latest /bin/sh
[root@luoahong2 ~]# docker run -it --network macvlan_1 --ip=10.0.0.112 busybox:latest /bin/sh / # ping 10.0.0.188 PING 10.0.0.188 (10.0.0.188): 56 data bytes 64 bytes from 10.0.0.188: seq=0 ttl=64 time=5.945 ms 64 bytes from 10.0.0.188: seq=1 ttl=64 time=0.699 ms 64 bytes from 10.0.0.188: seq=2 ttl=64 time=0.553 ms 64 bytes from 10.0.0.188: seq=3 ttl=64 time=0.611 ms 64 bytes from 10.0.0.188: seq=4 ttl=64 time=0.724 ms ^C --- 10.0.0.188 ping statistics --- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max = 0.553/1.706/5.945 ms / # ping 10.0.0.111 PING 10.0.0.111 (10.0.0.111): 56 data bytes 64 bytes from 10.0.0.111: seq=0 ttl=64 time=4.076 ms 64 bytes from 10.0.0.111: seq=1 ttl=64 time=0.670 ms 64 bytes from 10.0.0.111: seq=2 ttl=64 time=0.793 ms ^C --- 10.0.0.111 ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.670/1.846/4.076 ms
解決方案:注意主機名的惟一性spa
[root@luoahong ~]# ip link show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 00:0c:29:e7:b9:46 brd ff:ff:ff:ff:ff:ff [root@luoahong ~]# ip link set eth0 promisc on [root@luoahong ~]# ip link show eth0 2: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 00:0c:29:e7:b9:46 brd ff:ff:ff:ff:ff:ff [root@luoahong ~]# ip link set eth0 promisc off [root@luoahong ~]# ip link show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 00:0c:29:e7:b9:46 brd ff:ff:ff:ff:ff:ff
一、性能比較好,3d
二、有centos能夠把它看成物理機用 佔的資源更少blog
一、每次ip地址須要手動設置
二、兩臺主機共同用一個ip地址不會報錯,致使第三臺訪問有問題