编译OpenWrt全自动翻墙固件 for D-Link DIR-505 A1
除了增加模式转换开头,其他和编译 NetGear WNDR4300翻墙固件一样
你也可以直接下载编译好的翻墙固件: https://software-download.name/2014/dlink-dir-505-openwrt-fanqiang/
下载适合D-Link DIR505无线路由器的Image Builder
Image Builder又叫Image Generator,利用它我们可以方便地定制适合自己无线路由器的固件
选择 OpenWrt版本::
-
进入 http://downloads.openwrt.org/
-
Stable Release, 最后发行的稳定版本:
- OpenWrt 18.06.1
- Released: Sat, 18 Aug 2018
-
进入 http://downloads.openwrt.org/releases/18.06.1/targets/
选择 CPU 类型::
选择 ar71xx: http://downloads.openwrt.org/releases/18.06.1/targets/ar71xx/
选择 Flash 类型::
选择 generic:
http://downloads.openwrt.org/releases/18.06.1/targets/ar71xx/generic/
下载 Image Builder for DID-505:
-
页面搜索 dir-505 找到适合你的版本号,比如我的是 dir-505-a1
-
下载 Image Builder:
cd ~/Downloads wget http://downloads.openwrt.org/releases/18.06.1/targets/ar71xx/generic/openwrt-imagebuilder-18.06.1-ar71xx-generic.Linux-x86_64.tar.xz tar -xf openwrt-imagebuilder-18.06.1-ar71xx-generic.Linux-x86_64.tar.xz mv openwrt-imagebuilder-18.06.1-ar71xx-generic.Linux-x86_64 openwrt-imagebuilder-generic
确定OpenWrt无线路由器的PROFILE值
cd openwrt-imagebuilder-generic
make info
找到自己固件的型号,D-Link DIR 505 A1的PROFILE值是DIR505A1。如下图:
找出默认应该包含进OpenWrt固件的包
对于D-Link DIR-505 A1 无线路由器来说,可以这样获取:
echo $(wget -qO - http://downloads.openwrt.org/releases/18.06.1/targets/ar71xx/generic/config.seed | sed -ne 's/^CONFIG_PACKAGE_\([a-z0-9-]*\)=y/\1/ip')
2018-09的基础包:
libiwinfo-lua liblua liblucihttp liblucihttp-lua libubus-lua lua luci luci-app-firewall luci-base luci-lib-ip luci-lib-jsonc luci-lib-nixio luci-mod-admin-full luci-proto-ipv6 luci-proto-ppp luci-theme-bootstrap rpcd rpcd-mod-rrdns uhttpd
默认包:
运行命令:
make info
在顶部会列出:
Current Target: "ar71xx (Generic devices with GENERIC flash)" Default Packages:
base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd kmod-gpio-button-hotplug swconfig kmod-ath9k wpad-mini uboot-envtools dnsmasq iptables ip6tables ppp ppp-mod-pppoe firewall odhcpd-ipv6only odhcp6c
所有型号路由器共用包:
Default:
Default Profile
Packages:
kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport
特定路由器型号专属包,列出在PROFILE的下面,对于 DIR505A1:
kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport
自定义包:
wget bind-dig iptables-mod-tproxy kmod-ipt-tproxy ip-full dnsmasq-full simple-obfs libmbedtls libcares libev libsodium shadowsocks-libev
-
libmbedtls libcares libev libsodium shadowsocks-libev
shadowsocks-libev 及依赖,需要自己编译,或下编译好的包:
https://software-download.name/2014/shadowsocks-libev-polarssl-ar71xx-ipk-latest/
-
simple-obfs 是 shadowsocks-libev 混淆插件,需要自己编译,或下载编译好的包:
https://software-download.name/2014/shadowsocks-libev-polarssl-ar71xx-ipk-latest/
-
iptables-mod-tproxy kmod-ipt-tproxy ip-full 用于防火墙 UDP 转发
-
dnsmasq-full 需要配合 shadowsocks 客户端 ss-tunnel 使用
Dnsmasq 提供 DNS 缓存和 DHCP 服务功能。作为域名解析服务器(DNS),dnsmasq可以通过缓存 DNS 请求来提高对访问过的网址的连接速度。作为DHCP 服务器,dnsmasq 可以为局域网电脑提供内网ip地址和路由
默认的dnsmasq为base版本,该版本不能对特定的域名地址进行标记操作(因为我们需要对一些特定域名如twitter等进行标记),改为更加强大的dnsmasq-full
-
bind-dig 可以调试域名解析
上述包整合在一起并去重复。简单方法是复制到 Sublime Text, 以空格分隔,再用正则把空格 替换成 \n, 然后 Edit -> Permute Lines -> Unique
注意,在编译前要把自己编译的 shadowsocks-libev 及其他要用到的 .ipk 文件放到ImageBuilder的目录下packages
按照教程 编译shadowsocks-libev for OpenWrt ipk安装包
下载和设定自定义翻墙配置文件
下面以linux系统 ~/Downloads 下操作为例
cd ~/Downloads
git clone https://github.com/softwaredownload/openwrt-fanqiang
本地项目文件夹是: ~/Downloads/openwrt-fanqiang
建立一个配置文件夹,以路由器型号结束,如 ~/Downloads/openwrt-dir505
cd ~/Downloads
mkdir openwrt-dir505
cd openwrt-fanqiang
cp -R openwrt/default/* ~/Downloads/openwrt-dir505/
cp -R openwrt/dir505/* ~/Downloads/openwrt-dir505/
上面的操作,先复制共用的配置文件 openwrt/default/* 到 openwrt-dir505目录下
然后复制dir505专用的配置文件到 openwrt/dir505/* 到 openwrt-dir505目录下,如果有同名文件就覆盖
设置可执行权限
cd ~/Downloads/openwrt-dir505
chmod +x usr/bin
chmod +x usr/bin/*
chmod +x etc/uci-defaults
chmod +x etc/uci-defaults/*
说明:etc/uci-defaults目录下的文件会在路由器第一次启动时执行一次。在这里我们设置一些常用值
必须修改的DIR505翻墙配置文件:
-
~/Downloads/openwrt-dir505/etc/shadowsocks-libev/config.json
server改成你的服务器实际IP
-
~/Downloads/openwrt-dir505/usr/bin/router
wan-username 和 wan-password改成实际值
-
~/Downloads/openwrt-dir505/usr/bin/ss-firewall-asia
1.0.9.8必须改成你的服务器实际IP
自动复制和修改DIR-505翻墙设置文件
config-dir505.sh:
#!/bin/bash
# Author: https://github.com/softwaredownload/openwrt-fanqiang
# Date: 2015-12-24
REPOSITORY=~/Downloads/openwrt-fanqiang
CONFIG=~/Downloads/openwrt-dir505
createdir() {
rm -rf $CONFIG
mkdir $CONFIG
}
copy() {
cp -R $REPOSITORY/openwrt/default/* $CONFIG/
cp -R $REPOSITORY/openwrt/dir505/* $CONFIG/
}
setmod() {
chmod +x $CONFIG/usr/bin/ss-firewall-asia
chmod +x $CONFIG/etc/uci-defaults
chmod +x $CONFIG/etc/uci-defaults/*
}
modify() {
# server ip address
sed -i 's/1.0.9.8/server_ip/' $CONFIG/etc/shadowsocks-libev/config.json
# server_port
sed -i 's/1098/server_port/' $CONFIG/etc/shadowsocks-libev/config.json
# local_port
sed -i 's/7654/7654/' $CONFIG/etc/shadowsocks-libev/config.json
# password
sed -i 's/killgfw/killgfw/' $CONFIG/etc/shadowsocks-libev/config.json
# method
sed -i 's/chacha20-ietf-poly1305/chacha20-ietf-poly1305/' $CONFIG/etc/shadowsocks-libev/config.json
# server ip addresss
sed -i 's/1.0.9.8/server_ip/' $CONFIG/usr/bin/ss-firewall-asia
# local_port
sed -i 's/7654/7654/' $CONFIG/usr/bin/ss-firewall-asia
# ppoe username
sed -i 's/wan-username/wan-username/' $CONFIG/usr/bin/router
# ppoe password
sed -i 's/wan-password/wan-password/' $CONFIG/usr/bin/router
# wifi password
sed -i 's/icanfly9876/icanfly9876/g' $CONFIG/usr/bin/ap
sed -i 's/icanfly9876/icanfly9876/g' $CONFIG/usr/bin/router
# root password
sed -i 's/\\nfanqiang/\\nfanqiang/' $CONFIG/etc/uci-defaults/defaults
}
if [ "$1" = "createdir" ]; then
createdir
elif [ "$1" = "copy" ]; then
copy
elif [ "$1" = "setmod" ]; then
setmod
elif [ "$1" = "modify" ]; then
modify
else
echo "usage: createdir copy setmod modify"
fi
用法:在 config-dir505.sh所在目录运行:
./config-dir505.sh createdir
./config-dir505.sh copy
./config-dir505.sh setmod
./config-dir505.sh modify
开始编译OpenWrt自动翻墙固件
cd ~/Downloads/openwrt-imagebuilder
make image PROFILE=DIR505A1 PACKAGES="libiwinfo-lua liblua liblucihttp liblucihttp-lua libubus-lua lua luci luci-app-firewall luci-base luci-lib-ip luci-lib-jsonc luci-lib-nixio luci-mod-admin-full luci-proto-ipv6 luci-proto-ppp luci-theme-bootstrap rpcd rpcd-mod-rrdns uhttpd base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd kmod-gpio-button-hotplug swconfig kmod-ath9k wpad-mini uboot-envtools iptables ip6tables ppp ppp-mod-pppoe firewall odhcpd-ipv6only odhcp6c kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport wget bind-dig iptables-mod-tproxy kmod-ipt-tproxy ip-full dnsmasq-full simple-obfs libmbedtls libcares libev libsodium shadowsocks-libev -dnsmasq" FILES=~/Downloads/openwrt-dir505
编译好的的固件在ImageBuilder的bin/targets/ar71xx/目录下
然后把编译出的固件刷进路由器,重启路由器后后就能免设置智能翻墙
升级固件要用到的是 ...sysupgrade.bin,如果在原厂固件上刷要用 ...-factory.bin
先本地修改好配置文件再编译,然后把翻墙固件刷进D-Link DIR-505 A1后,就能零设置智能、自动翻墙
只要配置文件设置不出差错,编译固件一般都能成功,保存好这个固件,以后随便折腾路由器,出现问题大不了重刷一次,几分钟时间就一切都恢复正常
相关资源: