本文最后更新于:2020年5月9日 上午
基于coolsnowwolf大神源码编译,源码地址
一、 前言
自己编译需要linux知识、装系统的知识和能够全局的访问外网,而折腾openwrt需要部分计算机网络原理的知识。
如果不能自己编译,可以下载Lean大编译好的固件
也可以下载eSir大佬基于L大源码编译的固件。
二、 编译
2.1 搭建编译环境
首先打开Lean大的GitHub项目地址,仔细阅读说明,其实很简单,直接复制黏贴命令行就行。
然后虚拟机安装Ubuntu 18 LTS x64 Server版本
然后ssh登录Ubuntu,后面命令需要全局外网来进行编译了。
输入如下命令行
| sudo apt-get update
sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3.5 python2.7 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler g++-multilib antlr3 gperf
git clone https://github.com/coolsnowwolf/lede
cd lede
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
|
2.2 定制配置
make menuconfig
后,会有一个编译管理器,在里面可以选择型号、OP功能组件,需要用到方向键、回车键、空格键。方向键是移动光标,回车键是确认,空格键是选择(在选项框按下空格键,*号是编译进固件,M是编译但是不编译进固件)
下面的假如没有说明,就是默认选项。
①. Target System(Atheros AR7xxx…)
选择CPU型号,看你的CPU架构,软路由或虚拟机一般是是X86
②. Subtarget(x86_64)
选择多少位系统,默认64即可
③. Target Profile
选择路由型号,默认即可
④. Target Images
勾选上squashfs(new)即可,然后其他默认
⑤. Base system
选择默认的dnsmasq-full即可,另外2个dnsmasq切记不要选。
⑥. Administration
根据你的需求选择。
⑦. LuCI->Applications
整个系统精华所在,非常重要,常用配置如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
LuCI ---> Applications ---> luci-app-accesscontrol LuCI ---> Applications ---> luci-app-adbyby-plus LuCI ---> Applications ---> luci-app-aria2 LuCI ---> Applications ---> luci-app-arpbind LuCI ---> Applications ---> luci-app-autoreboot LuCI ---> Applications ---> luci-app-ddns LuCI ---> Applications ---> luci-app-filetransfer LuCI ---> Applications ---> luci-app-firewall LuCI ---> Applications ---> luci-app-hd-idle LuCI ---> Applications ---> luci-app-flowoffload LuCI ---> Applications ---> luci-app-sfe LuCI ---> Applications ---> luci-app-frpc LuCI ---> Applications ---> luci-app-ipsec-virtual**d LuCI ---> Applications ---> luci-app-mwan3 LuCI ---> Applications ---> luci-app-mwan3helper LuCI ---> Applications ---> luci-app-nlbwmon LuCI ---> Applications ---> luci-app-ramfree LuCI ---> Applications ---> luci-app-samba LuCI ---> Applications ---> luci-app-sqm
LuCI ---> Applications ---> luci-app-乳酸菌饮料-plus luci-app-乳酸菌饮料-plus ---> Include s-s v贰瑞 Plugin luci-app-乳酸菌饮料-plus ---> Include v贰瑞 luci-app-乳酸菌饮料-plus ---> Include Trojan luci-app-乳酸菌饮料-plus ---> Include red---socks2 luci-app-乳酸菌饮料-plus ---> Include Kcptun luci-app-乳酸菌饮料-plus ---> Include 违禁软件 Server
LuCI ---> Applications ---> luci-app-乳酸菌饮料server-python LuCI ---> Applications ---> luci-app-syncdial LuCI ---> Applications ---> luci-app-unblockmusic UnblockNeteaseMusic Golang Version UnblockNeteaseMusic NodeJS Version LuCI ---> Applications ---> luci-app-upnp LuCI ---> Applications ---> luci-app-vlmcsd LuCI ---> Applications ---> luci-app-vsftpd LuCI ---> Applications ---> luci-app-wifischedule LuCI ---> Applications ---> luci-app-wirele违禁软件egdb LuCI ---> Applications ---> luci-app-wol LuCI ---> Applications ---> luci-app-wrtbwmon LuCI ---> Applications ---> luci-app-xlnetacc LuCI ---> Applications ---> luci-app-zerotier Extra packages ---> ipv6helper Utilities ---> open-vm-tools
|
查看详细LuCI配置
⑧. Network->Download Manager
选择ariaNG
⑨. Utilities->Editors
1. 选择默认编辑器->nano,习惯vim的选择vim
2. 打开适用于VMware的VM Tools
Utilities —> open-vm-tools
⑩. 如果要支持 iPv6,勾选下面的选项:
Extra packages —> ipv6helper (选定这个后下面几项自动选择了)
Network —> odhcp6c
Network —> odhcpd-ipv6only
LuCI —> Protocols —> luci-proto-ipv6
LuCI —> Protocols —> luci-proto-ppp
离开选择功能界面,EXIT->YES
| make -j8 download V=s
make -j1 V=s
|
2.3 功能不满意?二次编译
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| make clean
cd lede
git pull
./scripts/feeds update -a && ./scripts/feeds install -a
rm -rf ./tmp && rm -rf .config
make menuconfig
make -jn V=99
|
2.4 全部LuCI->Applications配置
返回常用LuCI配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
LuCI ---> Applications ---> luci-app-accesscontrol LuCI ---> Applications ---> luci-app-acme LuCI ---> Applications ---> luci-app-adblock LuCI ---> Applications ---> luci-app-adbyby-plus LuCI ---> Applications ---> luci-app-adbyby LuCI ---> Applications ---> luci-app-adkill LuCI ---> Applications ---> luci-app-advanced-reboot LuCI ---> Applications ---> luci-app-ahcp LuCI ---> Applications ---> luci-app-airplay2 LuCI ---> Applications ---> luci-app-aliddns LuCI ---> Applications ---> luci-app-amule LuCI ---> Applications ---> luci-app-aria2 LuCI ---> Applications ---> luci-app-arpbind LuCI ---> Applications ---> luci-app-asterisk LuCI ---> Applications ---> luci-app-attendedsysupgrade LuCI ---> Applications ---> luci-app-autoreboot LuCI ---> Applications ---> luci-app-baidupcs-web LuCI ---> Applications ---> luci-app-bcp38 LuCI ---> Applications ---> luci-app-bird1-ipv4 LuCI ---> Applications ---> luci-app-bird1-ipv6 LuCI ---> Applications ---> luci-app-bird4 LuCI ---> Applications ---> luci-app-bird6 LuCI ---> Applications ---> luci-app-bmx6 LuCI ---> Applications ---> luci-app-bmx7 LuCI ---> Applications ---> luci-app-caldav LuCI ---> Applications ---> luci-app-cifs-mount LuCI ---> Applications ---> luci-app-cifsd LuCI ---> Applications ---> luci-app-cjdns LuCI ---> Applications ---> luci-app-clamav LuCI ---> Applications ---> luci-app-commands LuCI ---> Applications ---> luci-app-cshark LuCI ---> Applications ---> luci-app-ddns LuCI ---> Applications ---> luci-app-diag-core LuCI ---> Applications ---> luci-app-diskman luci-app-diskman ---> Include btrfs-progs luci-app-diskman ---> Include lsblk luci-app-diskman ---> Include mdadm luci-app-diskman ---> Include kmod-md-raid456 luci-app-diskman ---> Include kmod-md-linear LuCI ---> Applications ---> luci-app-dnscrypt-proxy LuCI ---> Applications ---> luci-app-dnsforwarder LuCI ---> Applications ---> luci-app-dnspod LuCI ---> Applications ---> luci-app-dockerman LuCI ---> Applications ---> luci-app-dump1090 LuCI ---> Applications ---> luci-app-dynapoint LuCI ---> Applications ---> luci-app-e2guardian LuCI ---> Applications ---> luci-app-familycloud LuCI ---> Applications ---> luci-app-filetransfer LuCI ---> Applications ---> luci-app-firewall LuCI ---> Applications ---> luci-app-flowoffload LuCI ---> Applications ---> luci-app-freifunk-diagnostics LuCI ---> Applications ---> luci-app-freifunk-policyrouting LuCI ---> Applications ---> luci-app-freifunk-widgets LuCI ---> Applications ---> luci-app-frpc LuCI ---> Applications ---> luci-app-frps LuCI ---> Applications ---> luci-app-fwknopd LuCI ---> Applications ---> luci-app-guest-wifi LuCI ---> Applications ---> luci-app-gfwlist LuCI ---> Applications ---> luci-app-haproxy-tcp LuCI ---> Applications ---> luci-app-hd-idle LuCI ---> Applications ---> luci-app-hnet LuCI ---> Applications ---> luci-app-ipsec-virtual**d LuCI ---> Applications ---> luci-app-kodexplorer LuCI ---> Applications ---> luci-app-kooldns LuCI ---> Applications ---> luci-app-koolproxy LuCI ---> Applications ---> luci-app-lxc LuCI ---> Applications ---> luci-app-meshwizard LuCI ---> Applications ---> luci-app-minidlna LuCI ---> Applications ---> luci-app-mjpg-streamer LuCI ---> Applications ---> luci-app-mtwifi LuCI ---> Applications ---> luci-app-mmc-over-gpio LuCI ---> Applications ---> luci-app-multiwan LuCI ---> Applications ---> luci-app-mwan LuCI ---> Applications ---> luci-app-music-remote-center LuCI ---> Applications ---> luci-app-mwan3 LuCI ---> Applications ---> luci-app-mwan3helper LuCI ---> Applications ---> luci-app-n2n_v2 LuCI ---> Applications ---> luci-app-netdata LuCI ---> Applications ---> luci-app-nfs LuCI ---> Applications ---> luci-app-nft-qos LuCI ---> Applications ---> luci-app-ngrokc LuCI ---> Applications ---> luci-app-nlbwmon LuCI ---> Applications ---> luci-app-noddos LuCI ---> Applications ---> luci-app-ntpc LuCI ---> Applications ---> luci-app-ocserv LuCI ---> Applications ---> luci-app-olsr LuCI ---> Applications ---> luci-app-olsr-services LuCI ---> Applications ---> luci-app-olsr-viz LuCI ---> Applications ---> luci-app-openvirtual** LuCI ---> Applications ---> luci-app-openvirtual**-server LuCI ---> Applications ---> luci-app-oscam LuCI ---> Applications ---> luci-app-p910nd LuCI ---> Applications ---> luci-app-pagekitec LuCI ---> Applications ---> luci-app-polipo LuCI ---> Applications ---> luci-app-pppoe-relay LuCI ---> Applications ---> luci-app-p p t p-server LuCI ---> Applications ---> luci-app-privoxy LuCI ---> Applications ---> luci-app-qbittorrent LuCI ---> Applications ---> luci-app-qos LuCI ---> Applications ---> luci-app-radicale LuCI ---> Applications ---> luci-app-ramfree LuCI ---> Applications ---> luci-app-rp-pppoe-server LuCI ---> Applications ---> luci-app-samba LuCI ---> Applications ---> luci-app-samba4 LuCI ---> Applications ---> luci-app-sfe LuCI ---> Applications ---> luci-app-s-s LuCI ---> Applications ---> luci-app-s-s-libes LuCI ---> Applications ---> luci-app-shairplay LuCI ---> Applications ---> luci-app-siitwizard LuCI ---> Applications ---> luci-app-simple-adblock LuCI ---> Applications ---> luci-app-smartdns LuCI ---> Applications ---> luci-app-softethervirtual** LuCI ---> Applications ---> luci-app-splash LuCI ---> Applications ---> luci-app-sqm LuCI ---> Applications ---> luci-app-squid LuCI ---> Applications ---> luci-app-乳酸菌饮料-plus luci-app-乳酸菌饮料-plus ---> Include s-s New Version luci-app-乳酸菌饮料-plus ---> Include s-s Simple-obfs Plugin luci-app-乳酸菌饮料-plus ---> Include s-s v贰瑞 Plugin luci-app-乳酸菌饮料-plus ---> Include v贰瑞 luci-app-乳酸菌饮料-plus ---> Include Trojan luci-app-乳酸菌饮料-plus ---> Include red---socks2 luci-app-乳酸菌饮料-plus ---> Include Kcptun luci-app-乳酸菌饮料-plus ---> Include 违禁软件 Server luci-app-乳酸菌饮料-plus ---> Include DNS2SOCKS luci-app-乳酸菌饮料-plus ---> Include 违禁软件 Socks and Tunnel(已弃) luci-app-乳酸菌饮料-plus ---> Include Socks Server LuCI ---> Applications ---> luci-app-乳酸菌饮料-pro LuCI ---> Applications ---> luci-app-乳酸菌饮料server-python LuCI ---> Applications ---> luci-app-statistics LuCI ---> Applications ---> luci-app-syncdial LuCI ---> Applications ---> luci-app-tinyproxy LuCI ---> Applications ---> luci-app-transmission LuCI ---> Applications ---> luci-app-travelmate LuCI ---> Applications ---> luci-app-ttyd LuCI ---> Applications ---> luci-app-udpxy LuCI ---> Applications ---> luci-app-uhttpd LuCI ---> Applications ---> luci-app-unblockmusic UnblockNeteaseMusic Golang Version UnblockNeteaseMusic NodeJS Version LuCI ---> Applications ---> luci-app-unblockneteasemusic-go LuCI ---> Applications ---> luci-app-unblockneteasemusic-mini LuCI ---> Applications ---> luci-app-unbound LuCI ---> Applications ---> luci-app-upnp LuCI ---> Applications ---> luci-app-usb-printer LuCI ---> Applications ---> luci-app-v贰瑞-server LuCI ---> Applications ---> luci-app-v贰瑞-pro LuCI ---> Applications ---> luci-app-verysync LuCI ---> Applications ---> luci-app-vlmcsd LuCI ---> Applications ---> luci-app-vnstat LuCI ---> Applications ---> luci-app-virtual**bypass LuCI ---> Applications ---> luci-app-vsftpd LuCI ---> Applications ---> luci-app-watchcat LuCI ---> Applications ---> luci-app-webadmin LuCI ---> Applications ---> luci-app-webshell LuCI ---> Applications ---> luci-app-wifischedule LuCI ---> Applications ---> luci-app-wireguard LuCI ---> Applications ---> luci-app-wirele违禁软件egdb LuCI ---> Applications ---> luci-app-wol LuCI ---> Applications ---> luci-app-wrtbwmon LuCI ---> Applications ---> luci-app-xlnetacc LuCI ---> Applications ---> luci-app-zerotier
|
2.5 自动编译
项目地址
自定义编译前需要在编译环境中运行./scripts/diffconfig.sh > diffconfig
然后把/lede/diffconfig
里内容替换项目里面相应的.config文件内容。
自动编译视频教程
三、 使用
3.1 初始设置
winscp登录Ubuntu系统,在/home/you_name/lede/bin/targets/x86/64/
下面
openwrt-x86-x64-combined-squashfs.img
就是我们需要的镜像文件了
把镜像文件下载下来,通过winPE
的U盘安装烧录到路由器硬盘里,也可以烧写到U盘里,通过U盘启动
网线连接到路由器的Lan口,默认登陆IP 192.168.1.1
, 密码 password
,进行配置(也可以通过PUTTY连接,端口22)
| vi /etc/config/network
/etc/init.d/network restart
|
网页地址栏输入192.168.10.1
,进行配置。
接线配置可参考如下2张图片
3.2 openwrt内部配置
网络 -> 接口 -> LAN口修改 -> IPv4地址 修改为访问路由的地址 -> 网关为路由ip地址 ->DNS填写114.114.114.114,119.29.29.29,223.5.5.5和你的网络运营商提供的DNS(可以在命令行中用ping ip来查看哪个DNS访问的最快) -> IPv6分配长度停用 -> 旁路由关闭DHCP,主路由开启动态DHCP
Turbo ACC 网络加速设置 -> 除了HWNAT硬件加速全选 -> 上游 DNS 服务器(国内) -> 查询填入你所在的网络运营商所提供的DNS查询地址1、查询地址2
旁路由不用设置wan口,主路由自行设置wan口,不用ipv6,最好关闭ipv6.
某科学的超电磁炮设置,①客户端—>分流服务器和主服务器相同,ip模式,DNS为默认8.8.4.4。②第二项自行添加。③高级设置开启自动切换。④服务端不设置不开启。⑤访问控制按需设置。
3.3 单网口openwrt小主机旁路由设置
- 登录主路由,设置LAN口IP地址,子网掩码为255.255.255.0 -> DHCP服务关闭 -> 保存。
- 网络 -> 接口 -> LAN修改 -> 基本设置 -> ip4地址 -> 网关为主路由LAN口IP地址 -> DNS服务器参考上面设置 -> IP6停用 -> 物理设置 -> 桥接接口不要勾选 -> 接口选择旁路由LAN口 -> -> 下方 -> -> -> DHCP服务器(启用即不要勾选忽略此接口) -> DHCP服务器高级设置 -> 勾选动态DHCP,强制 -> IP6设置可以关掉 -> 保存并应用。
参考
Lean大源码地址
OpenWrt 编译 LuCI -> Applications 添加插件应用说明
How to build your own Openwrt firmware
openwrt基础设置
OpenWrt中,旁路由的设置与使用