minger

minger

Ubuntu 22.04.4编译Openwrt

环境准备:
虚拟机准备好,cpu8 核,内存 4G,硬盘建议 40GB

一、更新软件#

sudo apt-get update
sudo apt-get upgrade

二、安装依赖#

sudo apt install -y ack antlr3 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-pyelftools \
libpython3-dev qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip \
vim wget xmlto xxd zlib1g-dev

三、编译固件#

1. 下载源代码,三个任选一个#

git clone https://github.com/openwrt/openwrt # 官方版本
git clone https://github.com/coolsnowwolf/lede # lede 版本
git clone -b 22.03 --single-branch https://github.com/Lienol/openwrt # lienol 版本

2. 添加插件或者主题#

上面的版本任意一个库克隆完毕后进入
打开 openwrt 文件夹,找到 feeds.conf.default 文件打开,添加到最下面!

src-git amlogic https://github.com/ophub/luci-app-amlogic   必须添加
src-git alist https://github.com/sbwml/luci-app-alist               Alist插件
src-git passwall_packages https://github.com/xiaorouji/openwrt-passwall.git;packages
src-git passwall_luci https://github.com/xiaorouji/openwrt-passwall.git;luci  
src-git kenzo https://github.com/kenzok8/openwrt-packages
src-git argonnew https://github.com/jerrykuku/luci-theme-argon.git;main    主题

3. 更新源码#

./scripts/feeds update -a # 更新源码
./scripts/feeds install -a # 拷贝源码

4. 定制插件#

make menuconfig

###### 如果需要重新配置 ##########
方法:使用命令
rm -rf ./tmp && rm -rf .config
make menuconfig
make V=s -j$(nproc)

5. 下载 dl 库,编译固件 (-j 后面是线程数)#

make -j8 download V=s  # 下载dl库,V=s 显示任务详细情况

make V=s -j8  # 8代表线程,根据个人实际情况调整

如果编译失败,可以执行以下命令:

“make clean” 删除编译目录 /bin 和 /build_dir 目录中的文件

“make dirclean” 除了删除编译目录之外还删除编译工具目录,删除 /bin 和 /build_dir 目录的中的文件 (make clean) 以及 /staging_dir、/toolchain、/tmp 和 /logs 中的文件,一般在更换 CPU 架构的情况下才操作。

6. 下载编译压缩包#

编译完成后输出路径:home / 用户名 /openwrt/bin/targets

附 小米 R4A 千兆版.config 配置文件#

CONFIG_TARGET_ramips=y
CONFIG_TARGET_ramips_mt7621=y
CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mi-router-4a-gigabit=y
CONFIG_PACKAGE_6in4=y
CONFIG_PACKAGE_frpc=y
CONFIG_PACKAGE_ip6tables=y
CONFIG_PACKAGE_ipv6helper=y
CONFIG_PACKAGE_kmod-ip6tables=y
CONFIG_PACKAGE_kmod-ipt-nat6=y
CONFIG_PACKAGE_kmod-iptunnel=y
CONFIG_PACKAGE_kmod-iptunnel4=y
CONFIG_PACKAGE_kmod-nf-ipt6=y
CONFIG_PACKAGE_kmod-nf-log6=y
CONFIG_PACKAGE_kmod-nf-nat6=y
CONFIG_PACKAGE_kmod-nf-reject6=y
CONFIG_PACKAGE_kmod-sit=y
CONFIG_PACKAGE_luci-app-frpc=y
CONFIG_PACKAGE_luci-app-nps=y
CONFIG_PACKAGE_luci-i18n-frpc-zh-cn=y
CONFIG_PACKAGE_luci-i18n-nps-zh-cn=y
CONFIG_PACKAGE_luci-theme-argon-mod=y
CONFIG_PACKAGE_npc=y

附:ubuntu 开通 root 登录 SSH 权限#

1. 使用普通用户登录后切换 root
sudo -i

2. 创建 root 管理员密码

passwd root

3. 开启 root 登录

sudo sed -i 's/^#?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config

4. 开启密码验证

sudo sed -i 's/^#?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config

5. 重启 ssh 服务

service sshd restart

附:开通 SSH 登录方法:#

1. 必须切换成为 root 用户

sudo -i

2. 先更新软件列表和更新软件

sudo apt-get update

3. 先更新软件列表和更新软件

sudo apt-get upgrade

4. 安装 ssh

apt-get install ssh

5. 启动 ssh 服务

sudo /etc/init.d/ssh start

加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。