docker network create -d macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 --ip-range=192.168.1.0/24 --ipv6 --subnet=fe00::/64 -o parent=eth0 subnet-macvlan
掩码 | 位数 | 可用主机数(主机地址数) |
---|---|---|
255.255.255.0 | 24 | 256-2=254 |
255.255.255.128 | 25 | 128-2=126 |
255.255.255.192 | 26 | 64-2=62 |
255.255.255.224 | 27 | 31-1=30 |
255.255.255.240 | 28 | 16-2=14 |
255.255.255.248 | 29 | 8-2=6 |
255.255.255.252 | 30 | 4-2=2 |
互通:
宿主机:192.168.1.1
subnet-macvlan:192.168.1.5
新建macvlan:192.168.1.3
ip link add macvlan link eth0 type macvlan mode bridge
ip addr add 192.168.1.3 dev macvlan
ip link set macvlan up
ip route add 192.168.1.5 dev macvlan
好好享受吧!!!