树莓派中利用docker搭建openwrt旁路由

树莓派中利用docker搭建openwrt旁路由

注意需要先查看内核信息(需要是aarch64)
uname -m
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镜像
docker pull unifreq/openwrt-aarch64:latest

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

docker images
5.创建并运行openwrt容器(创建openwrt_start.sh脚本)
#!/bin/bash
IP="192.168.0.200" #旁路由ip地址
MACADDR="02:42:C0:A8:00:02" #MAC地址,随机生成
IMG_TAG=latest
KERNEL_VERSION=$(uname -r)
docker run \
	        --name openwrt-${IMG_TAG} \
	        --restart always \
	        --network macnet \
	        --mac-address ${MACADDR} \
	        --ip ${IP} \
	        -d \
	        --privileged=true \
	        --ulimit nofile=16384:65536  \
	        -v /lib/modules/${KERNEL_VERSION}:/lib/modules/${KERNEL_VERSION} \
	        unifreq/openwrt-aarch64:$IMG_TAG
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
10.ctrl+D退出openwrt
11.浏览器访问之前设置的ip地址,默认密码password

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

unifreq/openwrt-aarch64地址
sulinggg/openwrt地址

  • 1
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值