Centos7中利用docker搭建openwrt旁路由

it2023-07-20  65

Centos7中利用docker搭建openwrt旁路由

1.查询当前网卡名称(以下均以网卡名eth0为例,请注意替换)

ifconfig

2.打开网卡混杂模式

ip link set eth0 promisc on

3.创建虚拟网络

docker network create -d macvlan --subnet=192.168.0.0/24 --gateway=192.168.0.1 -o parent=eth0 macnet

4.拉取openwrt镜像(以lean大神的openwrt为例)

docker pull ksafe/lean-openwrt:latest

拉取完毕之后查看一下拉取结果

docker images

5.创建并运行openwrt容器

docker run --restart always --name openwrt -d --network macnet --privileged ksafe/lean-openwrt:latest /sbin/init

6.查看openwrt容器运行状态,如果STATUS是UP则说明运行成功

docker ps -a

7.进入openwrt容器

docker exec -it openwrt /bin/sh

8.编辑配置文件

vim /etc/config/network

修改lan口内容

config interface 'lan' option type 'bridge' option ifname 'eth0' option proto 'static' option ipaddr '192.168.0.100' option netmask '255.255.255.0' option ip6assign '60' option gateway '192.168.0.1' option broadcast '192.168.0.255' option dns '192.168.0.1'

9.重启网络

/etc/init.d/network restart

docker中搭建openwrt到此结束,具体openwrt旁路由配置请参照百度或者google

最新回复(0)