假如路由器ip是192.168.2.1, 则:
mkdir /root/op
nano /root/op/network
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fde5:ed03:414e::/48'
config interface 'lan'
option type 'bridge'
option ifname 'eth0'
option proto 'static'
option ipaddr '192.168.2.2'
option netmask '255.255.255.0'
option ip6assign '60'
新建/op/ set_network.sh
nano /root/op/set_network.sh
#!/bin/bash
cp /share_data/network /etc/config/network
新建 /root/op/set_openwrt.sh
nano /root/op/set_openwrt.sh
#!/bin/bash
ip link set eth0 promisc on
docker stop openwrt
docker rm openwrt
docker network rm macnet
docker network create -d macvlan --subnet=192.168.2.0/24 --gateway=192.168.2.1 -o parent=eth0 macnet
docker run --restart always -d --network macnet --name openwrt --privileged -v /root/op:/share_data unifreq/openwrt-aarch64 /sbin/init
docker exec -it openwrt bash /share_data/set_network.sh
修改 /etc/rc.local 加入如下代码:
nano /etc/rc.local
ip link set eth0 promisc on
或者
ifconfig eth0 promisc
改完重启系统即可(完全启动完才生效,大概需要两三分钟)。
最后执行
bash /root/op/set_openwrt.sh
网友评论