由于netflix解锁不稳定,经常需要手动更换dns,于是写了个shell脚本来自动处理这些事
-rw-r--r-- 1 root root 145 3月 26 09:47 ip.txt
-rw-r--r-- 1 root root 105598 3月 28 12:00 log.log
-rwxr-xr-x 1 root root 647 3月 15 10:11 netflix.sh
-rwxr-xr-x 1 root root 4784128 12月 8 04:41 nf
其中nf是GitHub上的奈非检测程序
安装
wget -O nf https://github.com/sjlleo/netflix-verify/releases/download/2.61/nf_2.61_linux_amd64 && chmod +x nf && clear && ./nf
然后需要更换的dns从dns解锁服务商处获得,如下
5.180.78.164
195.85.19.45
103.149.46.114
最后是shell脚本
#!bin/bash
dir=$(cd "$(dirname "$0")";pwd)
c=0
for line in `cat $dir/ip.txt`
do
patter="^(\w+\.){3}\w+$"
if [[ "$line" =~ $patter ]]; then
ip=$line
array[$c]=$ip
((c++))
fi
done
check(){
info=`$dir/nf`
if [[ $info =~ "您的出口IP完整解锁Netflix" ]]; then
return 1
else
return 0
fi
}
check
if [[ $? == 1 ]]
then
exit;
fi
for i in ${!array[@]}
do
var=${array[i]}
sed -i "s/localdomain\^\$dnsrewrite=[^\']*/localdomain\^\$dnsrewrite=$var/g" /etc/AdGuardHome/AdGuardHome.yaml
$(/etc/AdGuardHome/AdGuardHome -s restart)
sleep 2
check
if [[ $? == 1 ]]
then
echo "替换成功:$var"
exit;
fi
done
本脚本配合adguardhome使用,服务器需要指定adguardHome解析dns,然后自定义过滤规则
#netflix
||localdomain^$dnsrewrite=5.180.78.164
||netflix.ca^$dnsrewrite=NXDOMAIN;;
||fast.com^$dnsrewrite=NXDOMAIN;;
||netflix.com^$dnsrewrite=NXDOMAIN;;
||netflix.net^$dnsrewrite=NXDOMAIN;;
||netflixinvestor.com^$dnsrewrite=NXDOMAIN;;
||netflixtechblog.com^$dnsrewrite=NXDOMAIN;;
||nflxext.com^$dnsrewrite=NXDOMAIN;;
||nflximg.com^$dnsrewrite=NXDOMAIN;;
||nflximg.net^$dnsrewrite=NXDOMAIN;;
||nflxsearch.net^$dnsrewrite=NXDOMAIN;;
||nflxso.net^$dnsrewrite=NXDOMAIN;;
||nflxvideo.net^$dnsrewrite=NXDOMAIN;;
||amazonaws.com^$dnsrewrite=NXDOMAIN;;
脚本会自动检测当前netflix是否解锁,并逐一使用ip.txt内的ip修改adguardHome配置,然后继续检测
netlfix.sh需要授予执行权限
chmod +x netflix.sh
配置定时任务以运行
*/2 * * * * bash /root/netflix/netflix.sh