Linux 0

    校园网Openwrt反多设备检查固件编译

    原地址:面对校园网的多设备检测,「我」的解决方案是——

    apt update -y
    apt full-upgrade -y
    apt install 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 python3 python3-pyelftools libpython3-dev qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev python3-setuptools -y

    GUI 界面询问是否启用 AppArmor ,选择 Yes

    #从此处开始请勿使用 root 账户执行,否则编译时将会被阻止
    git clone https://github.com/openwrt/openwrt.git --branch=openwrt-23.05
    cd openwrt
    
    #update feeds
    ./scripts/feeds update -a
    ./scripts/feeds install -a
    
    git clone https://github.com/Zxilly/UA2F.git package/UA2F
    git clone https://github.com/CHN-Beta/rkp-ipid.git package/rpk-ipid
    
    git clone https://github.com/jerrykuku/luci-theme-argon.git package/luci-theme-argon
    git clone https://github.com/jerrykuku/luci-app-argon-config.git package/luci-app-argon-config
    git clone https://github.com/lucikap/luci-app-ua2f.git package/luci-app-ua2f
    
    #update feeds
    ./scripts/feeds update -a
    ./scripts/feeds install -a
    
    echo "47964456485559d992fe6f536131fc64" > vermagic
    nano include/kernel-defaults.mk

    找到grep '=[ym]' $(LINUX_DIR)/.config.set | LC_ALL=C sort | $(MKHASH) md5 > $(LINUX_DIR)/.vermagic,将这行用#注释,下一行加入cp $(TOPDIR)/vermagic $(LINUX_DIR)/.vermagic

    nano package/kernel/linux/Makefile

    找到STAMP_BUILT:=$(STAMP_BUILT)_$(shell $(SCRIPT_DIR)/kconfig.pl $(LINUX_DIR)/.config | $(MKHASH) md5),将这行用#注释,下一行加入STAMP_BUILT:=$(STAMP_BUILT)_$(shell cat $(LINUX_DIR)/.vermagic)

    make menuconfig

    GUI 的配置界面中 Target部分需要按照硬件的实际情况选择
    新路由3 的配置如下

    Target System   => MediaTek Ralink MIPS
    Subtarget       => MT7621 based boards
    Target Profile  => D-Team Newifi D2

    GUI 配置界面下按/键可以进入搜索功能
    添加 IP-ID 模块

     Root -> Kernel modules -> Other modules -> [*] kmod-rkp-ipid

    添加 UA2F 模块

     Root -> Network -> Routing and Redirection -> [*] ua2f

    添加防火墙相关模块

     Root -> Network -> Firewall -> [*] iptables-mod-conntrack-extra
                                    [*] iptables-mod-filter
                                    [*] iptables-mod-ipopt
                                    [*] iptables-nft
                                    [*] iptables-mod-u32
     Root -> Network -> [*] ipset

    添加 LuCI 相关模块

     Root -> LuCI -> 1 -> [*] luci
                     2 -> [*] luci-compat
                     2 -> Translations -> [*] Chinese Simplified
                     3 -> [*] luci-app-argon-config
                          [*] luci-app-store
                          [*] luci-app-ttyd
                          [*] luci-app-ua2f

    配置完成,保存后退出

    开始内核编译配置

    make kernel_menuconfig -j$(nproc) V=cs

    最后会跳出 GUI 配置界面,需要进行一些配置

     Root -> Networking support -> Networking options -> [*] Network packet filtering framework (Netfilter)
     -> Core Netfilter Configuration -> [*] Netfilter NFNETLINK interface
                                        [*] Netfilter LOG over NFNETLINK interface
                                        [*] Connection tracking netlink interface
                                        [*] NFQUEUE and NFLOG integration with Connection Tracking

    保存后退出

    预下载编译所需的资源

    make download -j$(nproc) V=cs

    编译
    如果是使用 wsl 进行编译,最好在编译前将环境变量与 Windows 隔离,以免出现意外错误

    make -j$(nproc) V=cs

    其他参考:编译自己的openwrt固件 附编译好的newifi3固件