- 运行
ip add
命令查看网卡信息,例如 网络接口逻辑名称是 eth0
1 2 3 4 5 6 7
| 4: eth0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 32:7d:f1:57:9b:c8 brd ff:ff:ff:ff:ff:ff altname end0 inet 192.168.1.10/24 brd 192.168.1.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever inet6 fe80::23b9:deda:2f5f:8be2/64 scope link noprefixroute valid_lft forever preferred_lft forever
|
开启此网卡混杂模式。
1
| ip link set eth0 promisc on
|
1 2 3 4 5
| docker network create -d macvlan \ --subnet=192.168.1.0/24 \ --gateway=192.168.1.1 \ -o parent=eth0 \ wrt
|
注: 192.168.1.0/24 和 192.168.1.1 自行调整,为你局域网的网段
1 2 3 4 5 6 7 8 9
| docker run \ -d \ --name="openwrt" \ --network=wrt \ --privileged=true \ --restart=always \ --ulimit nofile=16384:65536 \ -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) \ summary/openwrt-aarch64:latest
|
1
| docker exec openwrt sed -e 's/192.168.1.1/192.168.1.99/' -i /etc/config/network
|
重启