4B Docker-OpenWrt安装
需要预先安装好docker之后
# 1.打开网卡混杂模式
sudo ip link set eth0 promisc on
# 2.创建网络 subnet 和 gateway 按自己的实况填写
docker network create -d macvlan --subnet=192.168.0.0/24 --gateway=192.168.0.1 -o parent=eth0 macnet
# 3.docker启动OpenWrt容器
docker run --restart always --name openwrt -d --network macnet --privileged sulinggg/openwrt /sbin/init
也可自行去 https://github.com/SuLingGG/OpenWrt-Docker 找适应自己系统的版本 本人测试latest适用4B,rpi4在4B-32位官方原系统无法启动
# 4.进入容器
docker exec -ti openwrt /bin/bash
# 5.把ip修改自己环境网段的ip
vim /etc/config/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'
config interface 'lan'
option ifname 'eth0'
option proto 'static'
option netmask '255.255.255.0'
option ipaddr '192.168.0.2'
option gateway '192.168.0.1'
option broadcast '192.168.0.0'
option dns '119.29.29.29 223.5.5.5 180.76.76.76'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 6.修改完成后重启network
/etc/init.d/network restart
之后可在浏览器登入network中设置的静态地址
编辑 (opens new window)