Skip to content

Latest commit

 

History

History
83 lines (50 loc) · 5 KB

6.dir505-build-image.md

File metadata and controls

83 lines (50 loc) · 5 KB

编译OpenWrt全自动翻墙固件 for D-Link DIR-505 A1

除了增加模式转换开头,其他和编译 TP-LINK WR2543N翻墙固件一样。

下载适合D-Link DIR505无线路由器的Image Builder

Image Builder又叫Image Generator,利用它我们可以方便地定制适合自己无线路由器的固件。

http://downloads.openwrt.org/snapshots/trunk/ 选择适合自己的目录,这里选:http://downloads.openwrt.org/snapshots/trunk/ar71xx/

cd /opt
wget http://downloads.openwrt.org/snapshots/trunk/ar71xx/OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64.tar.bz2
tar -xjf  OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64.tar.bz2

确定OpenWrt无线路由器的PROFILE值

cd OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64
make info

找到自己固件的型号,D-Link DIR 505 A1的PROFILE值是DIR505A1。如下图:

找出默认应该包含进OpenWrt固件的包

对于D-Link DIR-505 A1 无线路由器来说,可以这样获取:

echo $(wget -qO - http://downloads.openwrt.org/snapshots/trunk/ar71xx/config | sed -ne 's/^CONFIG_PACKAGE_\([a-z0-9-]*\)=y/\1/ip')

base-files busybox dnsmasq dropbear firewall fstools jsonfilter libc libgcc mtd netifd opkg procd swconfig ubox ubus ubusd uci kmod-crypto-aes kmod-crypto-arc4 kmod-crypto-core kmod-ledtrig-usbdev kmod-lib-crc-ccitt kmod-nls-base kmod-ip6tables kmod-ipt-conntrack kmod-ipt-core kmod-ipt-nat kmod-ipt-nathelper kmod-ipv6 kmod-ppp kmod-pppoe kmod-pppox kmod-slhc kmod-gpio-button-hotplug kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-ath kmod-ath9k kmod-ath9k-common kmod-cfg80211 kmod-mac80211 libip4tc libip6tc libxtables libblobmsg-json libiwinfo libjson-c libnl-tiny libubox libubus libuci ip6tables iptables hostapd-common iw odhcp6c odhcpd ppp ppp-mod-pppoe wpad-mini iwinfo jshn libjson-script uboot-envtools

以上默认包,我们要包含在PACKAGES命令行参数中,并再加上必要的包:wget shadowsocks-libev-polarssl,如果你需要网页管理界面,可以再加上luci。注意,在编译前要把 shadowsocks-libev-polarssl_1.x.x_ar71xx.ipk 放到 /opt/OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64/packages/base/ 目录下。

如果你的openWrt版本是 ATTITUDE ADJUSTMENT,可能要加上iptables-mod-nat-extra包,如果没安装的话iptables的端口转发会不支持。

下载和设定配置文件

下载配置文件

cd /opt
git clone https://github.com/softwaredownload/openwrt-fanqiang

配置文件目录就是:

/opt/openwrt-fanqiang/ebook/dir505/openwrt

不要直接在git项目修改添加你的个人网络配置,而是复制配置文件再修改。

cp -R /opt/openwrt-fanqiang/ebook/dir505/openwrt /opt/openwrt-dir505

然后修改 /opt/openwrt-dir505 中的相关配置文件。

设置可执行权限

cd /opt/openwrt-dir505
chmod +x usr/bin
chmod +x usr/bin/*
chmod +x etc/uci-defaults
chmod +x etc/uci-defaults/defaults

说明:etc/uci-defaults目录下的文件会在路由器第一次启动时执行一次。在这里我们设置一些常用值。

必须修改的配置文件:

  • /opt/openwrt-dir505/etc/shadowsocks.json
    • server改成你的服务器实际IP
  • /opt/openwrt-dir505/usr/bin/router
    • adslname 和 adslpassword改成实际值
  • /opt/openwrt-dir505/usr/bin/shadowsocks-firewall
    • 107.89.0.12必须改成你的服务器实际IP

开始编译OpenWrt自动翻墙固件

cd /opt/OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64
make image PROFILE=DIR505A1 PACKAGES="base-files busybox dnsmasq dropbear firewall fstools jsonfilter libc libgcc mtd netifd opkg procd swconfig ubox ubus ubusd uci kmod-crypto-aes kmod-crypto-arc4 kmod-crypto-core kmod-ledtrig-usbdev kmod-lib-crc-ccitt kmod-nls-base kmod-ip6tables kmod-ipt-conntrack kmod-ipt-core kmod-ipt-nat kmod-ipt-nathelper kmod-ipv6 kmod-ppp kmod-pppoe kmod-pppox kmod-slhc kmod-gpio-button-hotplug kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-ath kmod-ath9k kmod-ath9k-common kmod-cfg80211 kmod-mac80211 libip4tc libip6tc libxtables libblobmsg-json libiwinfo libjson-c libnl-tiny libubox libubus libuci ip6tables iptables hostapd-common iw odhcp6c odhcpd ppp ppp-mod-pppoe wpad-mini iwinfo jshn libjson-script uboot-envtools luci-ssl ipset wget shadowsocks-libev-polarssl" FILES=/opt/openwrt-dir505

编译好的的固件在 /opt/OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64/bin/ar71xx/目录,升级固件要用到的是 openwrt-ar71xx-generic-dir-505-a1-squashfs-sysupgrade.bin,如果在原厂固件上刷要用openwrt-ar71xx-generic-dir-505-a1-squashfs-factory.bin

然后把翻墙固件刷进D-Link DIR-505 A1,就能免设置智能翻墙,并定时自动更新规则。 只要配置文件设置不出差错,编译固件一般都能成功,保存好这个固件,以后随便折腾路由器,出现问题大不了重刷一次,几分钟时间就一切都恢复正常。

参考: