- 编译openwrt配置
- 打开混杂模式
- 配置macvlan网络
- 加载容器镜像
- 启动容器
- 进入容器修改网卡配置
- 参考文章
需要选择tar.gz
打开混杂模式ip link set ens33 promisc on ip link set ens34 promisc on配置macvlan网络
这里的网段和网关需要根据openwrt的配置
docker network create -d macvlan --subnet=172.16.60.0/24 --gateway=172.16.60.1 -o parent=ens33 -o macvlan_mode=bridge openwrt-LAN
根据物理网络进行配置
docker network create -d macvlan --subnet=192.168.0.0/24 --gateway=192.168.0.254 -o parent=ens34 -o macvlan_mode=bridge openwrt-WAN加载容器镜像
docker import openwrt-x86-64-generic-rootfs.tar.gz lean_openwrt启动容器
链接第二个网卡
docker run -it -d --restart always --network openwrt-LAN --privileged --name openwrt lean_openwrt /sbin/init docker network connect openwrt-WAN openwrt进入容器修改网卡配置
docker exec -it openwrt /bin/bash
vi /etc/config/network
config interface 'lan'
option type 'bridge'
option ifname 'eth0'
option proto 'static'
option ipaddr '172.16.60.1'
option netmask '255.255.255.0'
option ip6assign '64'
config interface 'wan'
option ifname 'eth1'
option proto 'dhcp'
option ip6assign '64'
/etc/init.d/network restart参考文章
https://openwrt.club/93.html



