LEDE是基于OpenWrt的Linux开源路由系统,集成了更多的功能。

注意

  • 不要用 root 用户进行编译
  • 也不能使用sudo来进行编译!!!
  • 国内用户编译前最好准备好梯子
  • 默认登陆IP 192.168.1.1 密码 password

编译命令

  • 首先装好 Linux 系统,推荐 Debian 11 或 Ubuntu LTS(我使用的是Debian 11)
  • 安装编译依赖
sudo apt update -y
sudo apt full-upgrade -y
sudo apt install -y ack antlr3 aria2 asciidoc autoconf automake autopoint binutils bison build-essential \
bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib \
git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libglib2.0-dev libgmp3-dev libltdl-dev \
libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libreadline-dev libssl-dev libtool lrzsz \
mkisofs msmtp nano ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pip libpython3-dev qemu-utils \
rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev
  • 更换国内镜像源依赖安装更快
#备份自带的软件源
mv /etc/apt/sources.list /etc/apt/sources.list.bak
#新建软件源文件
nano /etc/apt/sources.list
#添加以下内容(阿里云镜像源)	
deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
#更新一下软件仓库
apt-get update
  • 下载源代码,更新 feeds 并选择配置(在LEDE目录下输入命令)
git clone https://github.com/coolsnowwolf/lede
cd lede
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
  • 下载 dl 库,编译固件 (-j 后面是线程数,第一次编译推荐用单线程)
  • 该报错还是会报错,报错了再使用单线程排除故障
make download -j8
make V=s -j1

如果需要重新配置

#删除配置文件
rm -rf ./tmp && rm -rf .config
make menuconfig
make V=s -j$(nproc)
#仅清理编译结果(bin目录)
make clean
#清理所有编译文件(除了.config、dl文件夹和feeds以外都清理)
make dirclean
#清理所有编译文件以及相关依赖(完全清理干净,一键回到刚git clone下来的时候)
make distclean

编译固件报错处理

  • 使用普通用户权限编译提示错误

image-20230323200141666

  • 使用root权限编译提示you should not run configure as root

cce4cb51baa9497c4340a272430ec7a

  • 修改文件(夹)的拥有者为当前用户解决报错
cd ./lede/
sudo chown -R $USER lede

集成mentohust锐捷认证插件

  • 更新feeds
$ ./scripts/feeds update -a
$ ./scripts/feeds install libpcap
  • 克隆代码
# clone代码至package/路径下
$ git clone https://github.com/KyleRicardo/MentoHUST-OpenWrt-ipk.git package/mentohust
$ make menuconfig
  • 主菜单中找到Network,回车进入,然后找到mentohust

image-20230323201735543

  • 保存退出后编译固件
#编译固件
make V=s
#编译完成后在固件内的路径
/usr/sbin/mentohust