#1、添加下面的内容到 vi /etc/rc.local
ip link set eth0 promisc on
ip link add macnet-host link eth0 type macvlan mode bridge
ip addr add 10.10.10.63/32 dev macnet-host
ip link set macnet-host up
ip route add 10.10.10.32/27 dev macnet-host
#2、添加自定义子域网:
docker network create -d macvlan --subnet=10.10.10.0/24 --gateway=10.10.10.1 --ip-range 10.10.10.32/27 --aux-address="macnet-host=10.10.10.63" -o parent=eth0 macnet
#3、启动openwrt容器:
docker run --name openwrt --restart always -d --network macnet --hostname openwrt --ip 10.10.10.40 --privileged --label com.centurylinklabs.watchtower.enable=false ainigost/openwrt:latest
#4、修改容器LAN口地址:
docker exec -it openwrt sh
vi /etc/config/network
PS:把192.168.1.1改成10.10.10.40。
#5、登录openwrt后台,
[网络]--[接口]--[LAN]--[修改]--[物理设置]--[桥接接口去掉勾选]--[DHCP服务器基本设置]--[忽略此接口勾选]--[保存应用]
[网络]--[防火墙]--[自定义规则]--[添加:iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE ]--[重启防火墙]
PS:极度精简版,只包含上网plus插件。事例中的主路由地址为10.10.10.1,自己酌情修改。
Content type
Image
Digest
Size
15.6 MB
Last updated
over 6 years ago
docker pull ainigost/openwrt