哔哩哔哩视频教程:https://www.bilibili.com/video/BV1rnsCe1ErV
博主基本插件版本推荐编译配置:
16核心 20G内存 150G硬盘用于存储数据包以及编译包等

前情提要

1.需要准备能访问到外网域名的加速器(自己斟酌)

2.准备一个安装好的ubuntu虚拟机(或者直接使用海外服务器)

3.如果是国内,请在/etc/bash.bashrc内添加三行加速器给的端口地址

export http_proxy=http://192.168.100.1:7890
export https_proxy=http://192.168.100.1:7890
export ALL_PROXY=http://192.168.100.1:7890

4.首次ubuntu安装时候,可能是普通用户,这时你需要修改root密码后登录,为后面单独创建用户做准备

sudo passwd root
su - root

5.国内服务器源配置(没改国内的可以试试)

cat <<'EOF' > /etc/apt/sources.list
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.cernet.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.cernet.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.cernet.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.cernet.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.cernet.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.cernet.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
# deb https://mirrors.cernet.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# # deb-src https://mirrors.cernet.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.cernet.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.cernet.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
EOF

使用非root用户但是权限拉满

mkdir /openwrt
useradd -d /openwrt -s /bin/bash openwrt
chown openwrt:openwrt -R /openwrt
# ubuntu不支持 echo 123456 | passwd --stdin openwrt
passwd openwrt << EOF
123456
123456
EOF
echo "openwrt ALL=(ALL:ALL) ALL" >> /etc/sudoers
su - openwrt

环境安装

sudo apt update -y
sudo apt full-upgrade -y
sudo apt -y install lib32gcc-s1 
sudo apt update -y
sudo apt full-upgrade -y
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 libfuse-dev libglib2.0-dev libgmp3-dev \
libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libpython3-dev libreadline-dev \
libssl-dev libtool lrzsz mkisofs msmtp ninja-build p7zip p7zip-full patch pkgconf python3-full \
qemu-utils rsync scons squashfs-tools subversion swig texinfo \
uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev

克隆代码并配置

国内推荐

git clone -b openwrt-23.05 https://git.nju.edu.cn/nju/openwrt.git openwrt
cd openwrt
cat > feeds.conf.default <<EOF
src-git packages https://git.nju.edu.cn/nju/openwrt-packages.git;openwrt-23.05
src-git luci https://git.nju.edu.cn/nju/openwrt-luci.git;openwrt-23.05
src-git routing https://git.nju.edu.cn/nju/openwrt-routing.git;openwrt-23.05
src-git telephony https://git.nju.edu.cn/nju/openwrt-telephony.git;openwrt-23.05
src-git kenzo https://gitcode.com/nuoyis/openwrt-packages.git
src-git small https://gitcode.com/nuoyis/small.git
src-git smpackage https://gitcode.com/nuoyis/small-package.git
EOF

国外

git clone -b openwrt-23.05 https://github.com/openwrt/openwrt.git
cd openwrt
cat > feeds.conf.default <<EOF
src-git packages https://github.com/openwrt/packages.git;openwrt-23.05
src-git luci https://github.com/openwrt/luci.git;openwrt-23.05
src-git routing https://github.com/openwrt/routing.git;openwrt-23.05
src-git telephony https://github.com/openwrt/telephony.git;openwrt-23.05
src-git kenzo https://github.com/kenzok8/openwrt-packages.git
src-git small https://github.com/kenzok8/small.git
src-git smpackage https://github.com/kenzok8/small-package.git
#src-git video https://github.com/openwrt/video.git;openwrt-23.05
#src-git targets https://github.com/openwrt/targets.git;openwrt-23.05
#src-git oldpackages https://github.com/openwrt/packages.git;openwrt-23.05
#src-link custom /usr/src/openwrt/custom-feed
EOF

先执行查看是否还有报错

./scripts/feeds update -a
rm -rf ./feeds/smpackage/{base-files,dnsmasq,firewall*,fullconenat,libnftnl,nftables,ppp,opkg,ucl,upx,vsftpd*,miniupnpd-iptables,wireless-regdb,amule,luci-app-bandwidthd,UnblockNeteaseMusic-Go,luci-app-gowebdav,luci-app-fullconenat,natflow,natter,nps,luci-app-natter,luci-app-npc}
./scripts/feeds update -a -f
./scripts/feeds install -a -f

正常情况(有问题去看最后面):

openwrt@nuoyis:~/openwrt$ ./scripts/feeds install -a -f
Collecting package info: done
Installing all packages from feed packages.
Installing all packages from feed luci.
Installing all packages from feed routing.
Installing all packages from feed telephony.
Installing all packages from feed kenzo.
Installing all packages from feed small.
Installing all packages from feed smpackage.

主题更换

rm -rf package/lean/luci-theme-argon
find ./ -name luci-theme-argon | xargs rm -rf;
git clone https://github.com/jerrykuku/luci-theme-argon.git package/luci/luci-theme-argon
sed -i 's/luci-theme-bootstrap/luci-theme-argon/' feeds/luci/collections/luci/Makefile

准备好后执行这条命令配置

make menuconfig

配置常用插件

#此处来自https://www.moewah.com/archives/4003.html
## 插件类(可能需要自定义添加)
LuCI ---> Applications ---> luci-app-accesscontrol #上网时间控制
LuCI ---> Applications ---> luci-app-adbyby-plus   #去广告
LuCI ---> Applications ---> luci-app-arpbind  #IP/MAC绑定
LuCI ---> Applications ---> luci-app-autoreboot  #高级重启
LuCI ---> Applications ---> luci-app-aliddns   #阿里DDNS客户端
LuCI ---> Applications ---> luci-app-ddns   #动态域名 DNS
LuCI ---> Applications ---> luci-app-filetransfer  #y文件传输
LuCI ---> Applications ---> luci-app-firewall   #添加防火墙
LuCI ---> Applications ---> luci-app-frpc   #内网穿透 Frp
LuCI ---> Applications ---> luci-app-mwan3   #MWAN负载均衡
LuCI ---> Applications ---> luci-app-nlbwmon   #网络带宽监视器
LuCI ---> Applications ---> luci-app-ramfree  #释放内存
LuCI ---> Applications ---> luci-app-samba   #网络共享(Samba)
LuCI ---> Applications ---> luci-app-sqm  #流量智能队列管理(QOS)
LuCI ---> Applications ---> luci-app-openclash #你懂的那只猫
LuCI ---> Applications ---> luci-app-dnsfilter #广告过滤
LuCI ---> Applications ---> luci-app-passwall #不敢解释
LuCI ---> Applications ---> luci-app-mtwifi #闭源Wi-Fi驱动
LuCI ---> Applications ---> luci-app-eqos #根据IP控制网速
LuCI ---> Applications ---> luci-app-syncdial #薛定谔的多拨应用
LuCI ---> Applications ---> luci-app-zerotier #虚拟局域网
LuCI ---> Applications ---> luci-app-oaf #应用过滤神器
LuCI ---> Applications ---> luci-app-watchcat #断网检测功能与定时重启
LuCI ---> Applications ---> luci-app-wol   #WOL网络唤醒
LuCI ---> Applications ---> luci-app-wrtbwmon  #实时流量监测
LuCI ---> Applications ---> luci-app-upnp   #通用即插即用UPnP(端口自动转发)
LuCI ---> Applications ---> luci-app-argon-config #Argon主题设置
LuCI ---> Applications ---> luci-app-dockerman #docker安装程序

# 常用主题类
LuCI ---> Themes ---> luci-theme-argon

# 网络相关 (普通用户用不上)
Network ---> IP Addresses and Names ---> ddns-scripts_cloudflare.com-v4
Network ---> IP Addresses and Names --->  bind-dig
Network ---> Routing and Rediction ---> ip-full
Network ---> File Transfer ---> curl
Network ---> File Transfer ---> wget-ssl
Network ---> iperf3
Network ---> ipset
Network ---> socat #多功能的网络工具
Base system --> dnsmasq-full #DNS缓存和DHCP服务(dnsmasq-full和dnsmasq二者不可共存)

# 工具类 (普通用户用不上)
Utilities --> acpid  #电源管理接口(适用于x86平台)
Utilities --> Editors --> nano #Nano 编辑器
Utilities --> Shells --> bash #命令解释程序
Utilities --> disc --> eject #弹出可移动介质
Utilities --> disc --> fdisk #MBR分区工具
Utilities --> disc --> gdisk #GBT分区工具
Utilities --> disc --> lsblk #列出磁盘设备及分区查看工具
Utilities --> Filesystem --> resize2fs #调整文件系统大小
Utilities --> Filesystem --> e2fsprogs #Ext2(及Ext3/4)文件系统工具

# IPv6(未来运营商可能不再提供 IPv4 公网地址,有远程访问需求的建议加入)
Extra packages ---> ipv6helper (勾选此项即可,下面几项自动勾选)
Network ---> odhcp6c
Network ---> odhcpd-ipv6only
LuCI ---> Protocols ---> luci-proto-ipv6
LuCI ---> Protocols ---> luci-proto-ppp

脚本编译

cat > make.sh << EOF
rm -rf /tmp/*
./scripts/feeds update -a
./scripts/feeds install -a
make download -j$(nproc)
make V=s -j$(nproc)
EOF
chmod +x make.sh && ./make.sh

编译错误指南

错误1
WARNING: Makefile 'package/utils/busybox/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/busybox/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/busybox/Makefile' has a build dependency on 'libpam', which does not exist
WARNING: Makefile 'package/boot/kexec-tools/Makefile' has a dependency on 'liblzma', which does not exist
WARNING: Makefile 'package/network/services/lldpd/Makefile' has a dependency on 'libnetsnmp', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a dependency on 'libpam', which does not exist
WARNING: Makefile 'package/utils/policycoreutils/Makefile' has a build dependency on 'libpam', which does not exist
不管它,反正不影响什么

错误2
Collected errors:
 * check_data_file_clashes: Package libustream-openssl20201210 wants to install file /openwrt/openwrt/build_dir/target-x86_64_musl/root-x86/lib/libustream-ssl.so
        But that file is already provided by package  * libustream-mbedtls20201210
 * opkg_install_cmd: Cannot install package libustream-openssl20201210.
make[2]: *** [package/Makefile:71: package/install] Error 255
make[2]: Leaving directory '/openwrt/openwrt'
make[1]: *** [package/Makefile:124: /openwrt/openwrt/staging_dir/target-x86_64_musl/stamp/.package_install] Error 2
make[1]: Leaving directory '/openwrt/openwrt'
make: *** [/openwrt/openwrt/include/toplevel.mk:232: world] Error 2
这种需要执行
sed -i "s/CONFIG_PACKAGE_libustream-openssl=y/CONFIG_PACKAGE_libustream-openssl=n/" .config
或
sed -i "s/CONFIG_PACKAGE_libustream-libustream-mbedtls=m/CONFIG_PACKAGE_libustream-openssl=n/" .config
sed -i "s/CONFIG_PACKAGE_libustream-libustream-mbedtls=y/CONFIG_PACKAGE_libustream-openssl=n/" .config

错误3
Collected errors:
 * check_data_file_clashes: Package dnsmasq wants to install file /openwrt/openwrt/build_dir/target-x86_64_musl/root-x86/etc/hotplug.d/ntp/25-dnsmasqsec
        But that file is already provided by package  * dnsmasq-full
 * check_data_file_clashes: Package dnsmasq wants to install file /openwrt/openwrt/build_dir/target-x86_64_musl/root-x86/etc/init.d/dnsmasq
        But that file is already provided by package  * dnsmasq-full
 * check_data_file_clashes: Package dnsmasq wants to install file /openwrt/openwrt/build_dir/target-x86_64_musl/root-x86/etc/uci-defaults/50-dnsmasq-migrate-ipset.sh
        But that file is already provided by package  * dnsmasq-full
 * check_data_file_clashes: Package dnsmasq wants to install file /openwrt/openwrt/build_dir/target-x86_64_musl/root-x86/etc/uci-defaults/50-dnsmasq-migrate-resolv-conf-auto.sh
        But that file is already provided by package  * dnsmasq-full
 * check_data_file_clashes: Package dnsmasq wants to install file /openwrt/openwrt/build_dir/target-x86_64_musl/root-x86/usr/lib/dnsmasq/dhcp-script.sh
        But that file is already provided by package  * dnsmasq-full
 * check_data_file_clashes: Package dnsmasq wants to install file /openwrt/openwrt/build_dir/target-x86_64_musl/root-x86/usr/sbin/dnsmasq
        But that file is already provided by package  * dnsmasq-full
 * check_data_file_clashes: Package dnsmasq wants to install file /openwrt/openwrt/build_dir/target-x86_64_musl/root-x86/usr/share/acl.d/dnsmasq_acl.json
        But that file is already provided by package  * dnsmasq-full
 * check_data_file_clashes: Package dnsmasq wants to install file /openwrt/openwrt/build_dir/target-x86_64_musl/root-x86/usr/share/dnsmasq/dhcpbogushostname.conf
        But that file is already provided by package  * dnsmasq-full
 * check_data_file_clashes: Package dnsmasq wants to install file /openwrt/openwrt/build_dir/target-x86_64_musl/root-x86/usr/share/dnsmasq/rfc6761.conf
        But that file is already provided by package  * dnsmasq-full
 * opkg_install_cmd: Cannot install package dnsmasq.
make[2]: *** [package/Makefile:71: package/install] Error 255
make[2]: Leaving directory '/openwrt/openwrt'
make[1]: *** [package/Makefile:124: /openwrt/openwrt/staging_dir/target-x86_64_musl/stamp/.package_install] Error 2
make[1]: Leaving directory '/openwrt/openwrt'
make: *** [/openwrt/openwrt/include/toplevel.mk:232: world] Error 2

sed -i "s/CONFIG_PACKAGE_dnsmasq=y/CONFIG_PACKAGE_dnsmasq=n/" .config
最后修改:2024 年 09 月 23 日
如果觉得我的文章对你有用,请随意赞赏