硬件:ax3600:编译openwrt固件
差别
这里会显示出您选择的修订版和当前版本之间的差别。
硬件:ax3600:编译openwrt固件 [2022/01/07 00:22] – 创建 packingbox | 硬件:ax3600:编译openwrt固件 [2022/01/07 00:24] (当前版本) – packingbox | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== 编译并配置带 OpenClash 的 OpenWrt 固件 ====== | ||
+ | |||
+ | OpenWrt 是开源的、基于 Linux 的软路由系统,而 OpenClash 一个运行在 OpenWrt 上的 Clash 客户端,兼容Shadowsocks、Vmess、Trojan、Snell 等协议,根据灵活的规则配置策略代理,把 OpenClash 当网关做透明代理,该网段下的所有的设备无需设置,即可自动实现科学上网。 | ||
+ | |||
+ | 网上有很多修改过的 OpenWrt 固件,但集成 OpenClash 的固件比较少,本文将记录一下编译纯净的 OpenWrt 固件,并集成 OpenClash。 | ||
+ | |||
+ | ==== 前言 ==== | ||
+ | |||
+ | 系统我使用的 Debian 10 | ||
+ | |||
+ | 由于会下载大量国外数据,建议国内用户全程在科学上网环境下编译。 | ||
+ | |||
+ | 编译时会产生大量临时数据,建议至少预留20G的空闲空间和4G以上内存 | ||
+ | |||
+ | ==== 开始 ==== | ||
+ | |||
+ | 使用root用户安装所需软件依赖 | ||
+ | |||
+ | apt update | ||
+ | |||
+ | apt install build-essential ccache ecj fastjar file g++ gawk \ | ||
+ | |||
+ | gettext git java-propose-classpath libelf-dev libncurses5-dev \ | ||
+ | |||
+ | libncursesw5-dev libssl-dev python python2.7-dev python3 unzip wget \ | ||
+ | |||
+ | python3-distutils python3-setuptools python3-dev rsync subversion \ | ||
+ | |||
+ | swig time xsltproc zlib1g-dev curl | ||
+ | |||
+ | 以下操作全部以非root用户执行 | ||
+ | |||
+ | ## 切换到用户根目录 | ||
+ | |||
+ | cd ~ | ||
+ | |||
+ | ## 拉取OpenWrt | ||
+ | |||
+ | git clone [[https:// | ||
+ | |||
+ | ## 下载OpenClash | ||
+ | |||
+ | wget [[https:// | ||
+ | |||
+ | ## 解压 | ||
+ | |||
+ | unzip master.zip | ||
+ | |||
+ | ## 复制OpenClash软件包到OpenWrt | ||
+ | |||
+ | cp -r OpenClash-master/ | ||
+ | |||
+ | cd openwrt | ||
+ | |||
+ | ./ | ||
+ | |||
+ | ./ | ||
+ | |||
+ | 输入make menuconfig进入交互式配置界面 | ||
+ | |||
+ | * Target System (x86) ---> | ||
+ | * Subtarget (x86_64) | ||
+ | * Target Profile (Generic) | ||
+ | * Target Images | ||
+ | * Global build settings | ||
+ | * Advanced configuration options (for developers) | ||
+ | * Build the OpenWrt Image Builder 构建OpenWrt图像生成器 | ||
+ | * Build the OpenWrt SDK 构建OpenWrt SDK | ||
+ | * Package the OpenWrt-based Toolchain 打包基于OpenWrt的工具链 | ||
+ | * Image configuration | ||
+ | * Base system | ||
+ | * Administration | ||
+ | * Boot Loaders | ||
+ | * Development | ||
+ | * Extra packages | ||
+ | * Firmware | ||
+ | * Fonts ---> | ||
+ | * Kernel modules | ||
+ | * Languages | ||
+ | * Libraries | ||
+ | * LuCI ---> | ||
+ | * Mail ---> 邮件 | ||
+ | * Multimedia | ||
+ | * Network | ||
+ | * Sound ---> 声音 | ||
+ | * Utilities | ||
+ | * Xorg --->Xorg | ||
+ | |||
+ | ## 选择系统(以 x86_64 为例) | ||
+ | |||
+ | Target System -> x86 | ||
+ | |||
+ | Subtarget -> x86_64 | ||
+ | |||
+ | ## 选择固件的文件系统 | ||
+ | |||
+ | ## [[https:// | ||
+ | |||
+ | Target Images -> squashfs | ||
+ | |||
+ | ## 选择构建X86_X64的GRUB固件 | ||
+ | |||
+ | Target Images -> Build GRUB images (Linux x86 or x86_64 host only) | ||
+ | |||
+ | ## 选择更小的压缩格式固件,方便复制 | ||
+ | |||
+ | Target Images -> GZip images | ||
+ | |||
+ | ## 修改软件包可用空间,默认安装会占用100M左右,建议修改扩大,为后续安装其他软件打基础 | ||
+ | |||
+ | Target Images -> Root filesystem partition size | ||
+ | |||
+ | ## 添加web界面(y键选择n键排除) | ||
+ | |||
+ | LuCI > Collections -> Luci | ||
+ | |||
+ | ## 添加兼容性依赖 | ||
+ | |||
+ | LuCI > Modules -> luci-compat | ||
+ | |||
+ | ## 添加中文 | ||
+ | |||
+ | LuCI > Modules -> Translations -> Chinese Simplified | ||
+ | |||
+ | ## 添加openclash | ||
+ | |||
+ | LuCI > Applications -> luci-app-openclash | ||
+ | |||
+ | ## 添加主题 | ||
+ | |||
+ | LuCI -> Themes | ||
+ | |||
+ | ## 添加wget | ||
+ | |||
+ | Nerwork -> File Transfer -> wget-nossl | ||
+ | |||
+ | Nerwork -> File Transfer -> wget-ssl | ||
+ | |||
+ | ## 添加kmod-tun,TUN模式必须 | ||
+ | |||
+ | Kernel modules -> Network Support -> kmod-tun | ||
+ | |||
+ | ## 排除dnsmasq,由于默认会安装dnsmasq-full,这里需要排除dnsmasq,否则会冲突报错。 | ||
+ | |||
+ | Base system -> dnsmasq | ||
+ | |||
+ | 开始编译 | ||
+ | |||
+ | ## -j8: 使用8个内核,V=s: | ||
+ | |||
+ | ## 下载dl库(国内请尽量进行科学上网) | ||
+ | |||
+ | make -j8 download V=s | ||
+ | |||
+ | ## 开始编译 | ||
+ | |||
+ | make -j4 V=s | ||
+ | |||
+ | 编译时间很长,一般要30分钟以上 | ||
+ | |||
+ | 编译完成后的固件xx-squashfs-combined.img.gz在openwrt/ | ||
+ | |||
+ | 二次更新编译 | ||
+ | |||
+ | ## 切换到用户根目录 | ||
+ | |||
+ | cd ~ | ||
+ | |||
+ | ## 删除旧的openclash文件 | ||
+ | |||
+ | rm -rf master.zip && rm -rf OpenClash-master && rm -rf openwrt/ | ||
+ | |||
+ | ## 重新下载OpenClash | ||
+ | |||
+ | wget [[https:// | ||
+ | |||
+ | ## 解压 | ||
+ | |||
+ | unzip master.zip | ||
+ | |||
+ | ## 复制OpenClash软件包到OpenWrt | ||
+ | |||
+ | cp -r OpenClash-master/ | ||
+ | |||
+ | cd openwrt | ||
+ | |||
+ | ## 更新openwrt | ||
+ | |||
+ | git pull | ||
+ | |||
+ | ./ | ||
+ | |||
+ | ./ | ||
+ | |||
+ | ## 配置 | ||
+ | |||
+ | make menuconfig | ||
+ | |||
+ | ## 下载dl库(国内请尽量进行科学上网) | ||
+ | |||
+ | make -j8 download V=s | ||
+ | |||
+ | ## 开始编译 | ||
+ | |||
+ | make -j4 V=s | ||
+ | |||
+ | ===== ProxmoxVE安装OpenWrt ===== | ||
+ | |||
+ | 新建虚拟机,记住VM ID,这里以300为例;操作系统选择不使用任何介质;系统默认;硬盘随便分配1G,稍后需要手动删除的;CPU、内存、网络自行配置。 | ||
+ | |||
+ | 将编译好的 OpenWrt 固件放入 PVE 根目录。 | ||
+ | |||
+ | cd ~ | ||
+ | |||
+ | ## 解压固件 | ||
+ | |||
+ | gunzip xx-squashfs-combined.img.gz | ||
+ | |||
+ | ## 转换成 PVE 磁盘格式,注意其中的300替换为你的VM ID | ||
+ | |||
+ | qm importdisk 300 ./ | ||
+ | |||
+ | 转换完,在虚拟机硬件界面应该会多出一个未使用磁盘。将创建虚拟机时分配的磁盘分离删除,选择转换的 OpenWrt 磁盘点击编辑添加。 | ||
+ | |||
+ | 资料链接:[[https:// | ||
+ | |||