Loading... # Run openwrt on docker under Raspi4 ## Ready works ### 1. Open mixed network on reaspi4 ```bash bash > sudo ip link set eth0 promisc on ``` ### 2. Create the macvlan network > Note : Fill out the `xxxxx` ```bash bash > docker network create -d macvlan -subnet=192.168.xxx.x/24 -gateway=192.168.xxx.1 -o parent=eth0 macnet ``` ### 3. Check the networks ```bash bash > docker network ls ``` ### 4. Pull latest docker images ```bash # https://hub.docker.com/r/sulinggg/openwrt bash > docker pull sulinggg/openwrt:rpi4 ``` ## Start Config ### 1. Create Container ```bash bash > docker run –restart always –name openwrt -d –network macnet -v /etc/resolv.conf:/etc/resolv.conf –privileged sulinggg/openwrt:rpi4 /sbin/init ``` ### 2. Config Container Network ```bash # enter the container bash > docker exec -it openwrt sh # alter config **** bash > vim /etc/config/network # restart container network bash > /etc/init.d/network restart ``` --- ```config config interface 'lan' option type 'bridge' option ifname 'eth0' option proto 'static' option ipaddr '192.168.xxx.10' option netmask '255.255.255.0' option ip6assign '60' option gateway '192.168.xxx.1' option broadcast '192.168.xxx.255' option dns '192.168.xxx.1' ``` ### 3. Firewall Setting ```config # One eth0 iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE ``` ## Some Attention ### 1. Raspi4 network problem > Comfirm the network config in your raspi4 ```bash bash > vim /etc/network/interfaces ``` --- ```config auto eth0 iface eth0 inet manual auto macvlan iface macvlan inet static address 192.168.xxx.xxx netmask 255.255.255.0 gateway 192.168.xxx.xxx dns-nameservers 192.168.xxx.xxx pre-up ip link add macvlan link eth0 type macvlan mode bridge post-down ip link del macvlan link eth0 type macvlan mode bridge ``` Last modification:September 3, 2022 © Reprint prohibited Support Appreciate the author AliPayWeChat Like 0 If you think my article is useful to you, please feel free to appreciate