侧边栏壁纸
博主头像
AngusWong's博客 博主等级

行动起来,活在当下

  • 累计撰写 25 篇文章
  • 累计创建 26 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

编译自己的路由器系统Openwrt

Administrator
2021-02-22 / 0 评论 / 0 点赞 / 3 阅读 / 0 字
[h2title]一、Ubuntu系统安装[/h2title] 准备系统Ubuntu系统(版本选择16.04或者18.04) 系统可以各大运营商的vps云服务器也可以使用虚拟机下载安装系统。 下载地址:https://cn.ubuntu.com/download,可以选择下图所示地址下载旧版本的Ubuntu [h2title]二、更新系统,安装依赖包[/h2title] 1、通过SSH登陆Ubuntu系统,升级系统 sudo apt-get update
sean@sean:~$ sudo apt-get update
[sudo] password for sean:
Hit:1 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:3 http://cn.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:4 http://cn.archive.ubuntu.com/ubuntu bionic-security InRelease
Reading package lists... Done
2、输入sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch 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 安装需要的依赖   [h2title]三、下载源码[/h2title] 1、源码选择 Lean的源码: https://github.com/coolsnowwolf/lede
sean@sean:~$ git clone https://github.com/coolsnowwolf/lede
Cloning into 'lede'...
remote: Enumerating objects: 78030, done.
remote: Total 78030 (delta 0), reused 0 (delta 0), pack-reused 78030
Receiving objects: 100% (78030/78030), 250.77 MiB | 3.96 MiB/s, done.
Resolving deltas: 100% (42188/42188), done.
sean@sean:~$ cd lede/
sean@sean:~/lede$ ./scripts/feeds update -a
....
sean@sean:~/lede$ ./scripts/feeds install -a
....
Installing package 'rtpengine' from telephony
Installing package 'rtpproxy' from telephony
Installing package 'sipgrep' from telephony
Installing package 'sipp' from telephony
Installing package 'siproxd' from telephony
Installing package 'sngrep' from telephony
Installing package 'yate' from telephony
Installing all packages from feed freifunk.
Installing package 'luci-theme-freifunk-generic' from freifunk
sean@sean:~/lede$
  Lienol的源码:https://github.com/Lienol/openwrt
sean@sean:~$ git clone -b 19.07 --single-branch https://github.com/Lienol/openwrt openwrt19
Cloning into 'openwrt19'...
remote: Enumerating objects: 467084, done.
remote: Total 467084 (delta 0), reused 0 (delta 0), pack-reused 467084
Receiving objects: 100% (467084/467084), 195.23 MiB | 3.94 MiB/s, done.
Resolving deltas: 100% (316001/316001), done.
sean@sean:~$ cd openwrt19/
sean@sean:~/openwrt19$ ./scripts/feeds update -a
......
sean@sean:~/openwrt19$ ./scripts/feeds install -a
Installing package 'sngrep' from telephony 
Installing package 'yate' from telephony 
Installing all packages from feed freifunk. 
Installing package 'luci-theme-freifunk-generic' from freifunk
sean@sean:~/openwrt19$
  [h2title]四、编译前配置[/h2title] 1、修改默认IP地址 Openwrt默认IP地址是192.168.1.1,这个地下跟光猫地址相同,会有冲突,建议编译前修改一个。 修改源码目录下的 package/base-files/files/bin/config_generate 文件,修改如下图所在行的IP地址。
sean@sean:~$ cd lede/
sean@sean:~/lede$ nano package/base-files/files/bin/config_generate
2、修改配置 在主目录输入 make menuconfig 进入配置页面 (1)在下图几个选项中设置目标和生成的镜像 (2)如查需要使用Ipv6进入 Extra packages 选项选择ipv6helper (3) 如果需要动态域名,并且域名是托管到cloudflare、freedns、godaddy等上面的,请到network>IP address and Names 选择下面选择对应的组件(如下图,我选择了cloudflare)这样编译后的固件可以支持对应平台域名的动态修改 (4)最重要的就这一步了,进入LuCI > 3.Applications选择需要人功能 (5)选择支持的皮肤(第三方皮肤可以自动网上寻找来按教程下载到对应目录) 选择好后选择Save保存 [h2title]五、正式编译[/h2title] 由于编译系统花费的时候很长,使用SSH远程服务时可能会断开倒致编译失败,故推荐使用Screen 常用的几个命令: screen -S name 启动一个名字为name的screen screen -S name -X quit 删除某个session screen -ls 是列出所有的screen screen -r name或者id,就可以回到某个screen了(如不行先detached: screen -d name) ctrl + a + d 可以回到前一个screen,当时在当前screen运行的程序不会停止   先启动一个screen
sean@sean:~/lede$ screen -S openwrt

sean@sean:~/lede$ screen -ls
There is a screen on:
        18539.openwrt   (02/21/2021 12:40:23 PM)        (Attached)
1 Socket in /run/screen/S-sean.
下载需在的dl库,这个需要的时间也比较长,请耐心等待 make -j8 download V=s 下载完成后,正式编译 make -j1 V=s
sean@sean:~/lede$ make -j8 download V=s
make[1]: Entering directory '/home/sean/lede/scripts/config'
cc -O2   -c -o conf.o conf.c
cc   conf.o confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o symbol.o util.o   -o conf
make[1]: Leaving directory '/home/sean/lede/scripts/config'
time: target/linux/prereq#0.08#0.01#0.09
make[1]: Entering directory '/home/sean/lede'
+ mkdir -p /home/sean/lede/staging_dir/target-x86_64_musl
+ mkdir -p /home/sean/lede/staging_dir/host
+ cd /home/sean/lede/staging_dir/target-x86_64_musl
+ mkdir -p bin lib stamp
+ cd /home/sean/lede/staging_dir/host
......
sean@sean:~/lede$ make -j1 V=s
......
make[2]: Entering directory '/home/sean/lede'
make[2]: Nothing to be done for 'json_overview_image_info'.
make[2]: Leaving directory '/home/sean/lede'
export MAKEFLAGS= ;make -w -r checksum
make[2]: Entering directory '/home/sean/lede'
make[2]: Leaving directory '/home/sean/lede'
make[1]: Leaving directory '/home/sean/lede'
sean@sean:~/lede$
编译结果在bin/targets/xxx/xxx 目录下,如果是x86软路由,则在bin/targets/x86/64/目录   [h2title]六、命令总结[/h2title] 首次编译:
git clone https://github.com/coolsnowwolf/lede
cd lede
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
make download -j8
make V=s -j1
二次编译:
cd lede
git pull
./scripts/feeds update -a
./scripts/feeds install -a
make defconfig
make download -j8
make V=s -j$(nproc)
如果需要修改配置:
rm -rf ./tmp && rm -rf .config
make menuconfig
make V=s -j$(nproc)
 
0

评论区