环境配置说明
1 2 3 4 5 6 7 8 9 sudo apt-get updatesudo apt-get install build-essential asciidoc binutils bzip2 \gawk gettext git libncurses5-dev libz-dev patch unzip zlib1g-dev \ lib32gcc1 libc6-dev-i386 subversion flex uglifyjs libssl-dev upx \ gcc-multilib p7zip p7zip-full msmtp texinfo libglib2.0-dev xmlto \ git-core qemu-utils libelf-dev autoconf automake libtool autopoint \ curl wget device-tree-compiler rsync
获取编译源码
注意:不要使用root用户编译,最好使用梯子来加速源码的下载速度
编译完成后把bin/targets/brcm27xx/bcm2711/openwrt-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz解压后的img文件刷入SD卡中即可
可选lean版魔改源码替换官方源码:https://github.com/coolsnowwolf/lede
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 mkdir openwrtcd openwrt/git clone https://git.openwrt.org/openwrt/openwrt.git ./ git pull ./scripts/feeds update -a ./scripts/feeds install -a make defconfig make menuconfig make download -j8 V=s make -j1 V=s make clean make dirclean make distclean
可选内核配置 1 2 3 4 5 6 7 8 9 make kernel_menuconfig
固件编译配置
简单的make menuconfig参数配置,除必选配置外的其他项可根据需求自行选择
基础配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Target System -> Broadcom BCM27xx Subtarget -> BCM2711 boards (64 bit) Target Profile -> Raspberry Pi 4B Target Images -> ext4 Target Images -> squashfs Target Images -> Kernel partition size = 64 Target Images -> Root filesystem partition size = 512 Base system -> block-mount Base system -> blockd Base system -> wireless-tools Administration -> htop Firmware -> xxx
内核模块
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 Kernel modules -> Filesystems -> kmod-fs-ext4 Kernel modules -> Filesystems -> kmod-fs-ntfs Kernel modules -> Filesystems -> kmod-fs-squashfs Kernel modules -> Filesystems -> kmod-fs-vfat Kernel modules -> Filesystems -> kmod-fuse Kernel modules -> Network Devices -> kmod-xxx Kernel modules -> Wireless Drivers -> kmod-rt2800-usb Kernel modules -> USB Support -> kmod-usb-net -> kmod-usb-net-sr9700 Kernel modules -> USB Support -> kmod-usb-net -> kmod-usb-net-rtl8152 Kernel modules -> USB Support -> kmod-usb-net -> kmod-usb-net-asix Kernel modules -> USB Support -> kmod-usb-net -> kmod-usb-net-asix-ax88179 Kernel modules -> USB Support -> kmod-usb-core Kernel modules -> USB Support -> kmod-usb-hid Kernel modules -> USB Support -> kmod-usb-ohci Kernel modules -> USB Support -> kmod-usb-uhci Kernel modules -> USB Support -> kmod-usb-storage Kernel modules -> USB Support -> kmod-usb-storage-extras Kernel modules -> USB Support -> kmod-usb-usb2 Kernel modules -> USB Support -> kmod-usb-usb3
LuCI配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 LuCI -> Collections -> luci LuCI -> Modules -> Translations -> Chinese(zh-cn) LuCI -> Themes -> luci-theme-material LuCI -> Applications -> luci-app-aria2 LuCI -> Applications -> luci-app-firewall LuCI -> Applications -> luci-app-hd-idle LuCI -> Applications -> luci-app-opkg LuCI -> Applications -> luci-app-qos LuCI -> Applications -> luci-app-samba4 LuCI -> Applications -> luci-app-frpc LuCI -> Applications -> luci-app-shadowsocks-libev LuCI -> Applications -> luci-app-upnp LuCI -> Applications -> luci-app-wol ......
其他工具
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Network -> Download Manager -> ariang Network -> File Transfer -> Aria2 Configuration -> *** Network -> File Transfer -> curl Network -> File Transfer -> wget Utilities -> Compression -> bsdtar Utilities -> Compression -> gzip Utilities -> Compression -> xz-utils Utilities -> Compression -> unzip Utilities -> Compression -> zip Utilities -> Disc -> fdisk Utilities -> Disc -> lsblk Utilities -> Editors -> vim Utilities -> Filesystem -> ntfs-3g Utilities -> Filesystem -> resize2fs Utilities -> Terminal -> screen Utilities -> pciutils Utilities -> usbutils
IPv6支持
1 2 3 4 5 6 Global build settings -> Enable IPv6 support in packages Network -> odhcp6c Network -> odhcpd-ipv6only Network -> Firewall -> ip6tables LuCI -> Protocols -> luci-proto-ipv6
手动配置网卡
用网线连接自己的电脑和树莓派,LEDE默认的IP为静态 192.168.1.1,可以将电脑网卡设置为静态IP:192.168.1.2 来访问树莓派上的LEDE管理界面。
设置2.4G无线:网络 -> 无线 选项卡中点修改,基本设置中设置为Legacy模式,频宽2.4GHz和信道自选(切勿使用自动信道和自动频宽),高级设置中国家代码AU。接口配置中模式:接入点AP,网络:lan,然后设置无线安全加密WPA2-PSK和密码等,其余默认即可。
设置5G无线:网络 -> 无线 选项卡中点修改,基本设置中设置为AC模式,只能使用36信道和频宽为20Mhz或者40Mhz才能用作AP(切勿使用自动信道和自动频宽),高级设置中国家代码AU。接口配置中模式:接入点AP,网络:lan,然后设置无线安全加密WPA2-PSK和密码等,其余默认即可。
设置WAN口 网络 -> 接口 选项卡中添加一个新接口命名为”wan”,协议根据自己的网络情况自行选择(我的是DHCP客户端),在 物理设置 中单选接口为eth0,先保存但别应用。设置LAN口 网络 -> 接口 选项卡中编辑lan网卡的物理设置,在无线网络和自定义接口上打上钩填上”eth0.1”, 并取消原本eth0前的钩后保存。
自动配置网卡
在openwrt目录下新建一个名为files的文件夹,openwrt在编译的时候,会把files文件夹里的文件编译到固件的根目录。 在files/etc/config/中新建两个文件:network,wireless内容如下用来分别配置接口和无线
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 config interface 'loopback' option ifname 'lo' option proto 'static' option ipaddr '127.0.0.1' option netmask '255.0.0.0' config globals 'globals' option ula_prefix 'fd38:13ae:ceeb::/48' config interface 'lan' option type 'bridge' option proto 'static' option ipaddr '192.168.1.1' option netmask '255.255.255.0' option ip6assign '60' option ifname 'eth0.1' option _orig_ifname 'eth0 wlan0' option _orig_bridge 'true' config interface 'wan' option ifname 'eth0' option proto 'dhcp' option _orig_ifname 'erspan0' option _orig_bridge 'false'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 config wifi-device 'radio0' option type 'mac80211' option channel '36' option hwmode '11a' option path 'platform/soc/fe300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:0001:1' option htmode 'VHT40' config wifi-iface 'default_radio0' option device 'radio0' option mode 'ap' option encryption 'none' option ssid 'RPI4' option network 'lan'
其他实用技巧
系统 -> LED配置中:LED0是绿色灯,LED1是红色灯,可以用来当无线收发的指示灯
使用:cat /sys/class/thermal/thermal_zone0/temp
查看CPU温度
在Samba中使用root用户除了执行smbpasswd -a root添加用户外,还需要注释模板中的:#invalid users = root
使用Win10 WSL环境编译的,编译前建议先将Win10系统变量剔除,否则可能报错:export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
单核编译大概需要4个小时,中间可能会有几次错误,有的错误可跳过对后续编译没有影响
在OpenWRT的 .config
文件中内核的选项都是形如 CONFIG_KERNEL_XXX
。自己手动添加内核选项时不要忘了在中间添加 _KERNEL_
前缀。
Goproxy代理失败报错的解决方法:export GO111MODULE=on
和 export GOPROXY=https://goproxy.cn
1 2 go: github.com/armon/go-socks5@v0.0.0-20160902184237-e75332964ef5: Get "https://proxy.golang.org/github.com/armon/go-socks5/@v/v0.0.0-20160902184237-e75332964ef5.mod" : dial tcp 172.217.27.145:443: connect: connection refused