使用dnsmasq搭建Netflix等流媒体解锁DNS
手动搭建简单写一下做记录,参考网址https://github.com/myxuchangbin/dnsmasq_sniproxy_install,不想了解过程直接搭建的请访问这个网址。
准备工作
一些流媒体必须指定IP范围内才可以观看,因为业务广泛,各地区、国家等法律法规不同,无可厚非。
准备: 一台能看奈飞(Netflix)的vps,此处Centos7。
原理: 使用dnsmasq搭建dns服务器,把奈飞的域名IP解析到自己的VPS上面,然后使用sniproxy反代奈飞网站,来实现访问vps等同访问奈飞的效果(过程就是vps使用sniproxy转发你的流量到奈飞),别的网址也可以以此类推。
搭建dns服务器
安装dnsmasq
yum install dnsmasq -y
此处记得关闭防火墙或者开放53端口供访问做dns解析。
配置
然后在/etc/dnsmasq.d 文件夹内随便创建一个conf文件,此处以net.conf文件为例,然后内容为下(内容参考开头写的连接内容资料,不保证以后的可用性和变更),其中127.0.0.1换成你的vps的IP地址,其中的ip.sb是一个查询IP的网址,搭建完成后用来测试的。
domain-needed
bogus-priv
no-resolv
no-poll
all-servers
server=8.8.8.8
server=1.1.1.1
server=208.67.222.222
server=4.2.2.1
cache-size=2048
local-ttl=60
interface=*
address=/ip.sb/127.0.0.1
address=/akadns.net/127.0.0.1
address=/akam.net/127.0.0.1
address=/akamai.com/127.0.0.1
address=/akamai.net/127.0.0.1
address=/akamaiedge.net/127.0.0.1
address=/akamaihd.net/127.0.0.1
address=/akamaistream.net/127.0.0.1
address=/akamaitech.net/127.0.0.1
address=/akamaitechnologies.com/127.0.0.1
address=/akamaitechnologies.fr/127.0.0.1
address=/akamaized.net/127.0.0.1
address=/edgekey.net/127.0.0.1
address=/edgesuite.net/127.0.0.1
address=/srip.net/127.0.0.1
address=/footprint.net/127.0.0.1
address=/level3.net/127.0.0.1
address=/llnwd.net/127.0.0.1
address=/edgecastcdn.net/127.0.0.1
address=/cloudfront.net/127.0.0.1
address=/netflix.com/127.0.0.1
address=/netflix.net/127.0.0.1
address=/nflximg.net/127.0.0.1
address=/nflxvideo.net/127.0.0.1
address=/nflxso.net/127.0.0.1
address=/nflxext.com/127.0.0.1
address=/hulu.com/127.0.0.1
address=/huluim.com/127.0.0.1
address=/hbonow.com/127.0.0.1
address=/hbogo.com/127.0.0.1
address=/hbo.com/127.0.0.1
address=/amazon.com/127.0.0.1
address=/amazon.co.uk/127.0.0.1
address=/amazonvideo.com/127.0.0.1
address=/crackle.com/127.0.0.1
address=/pandora.com/127.0.0.1
address=/vudu.com/127.0.0.1
address=/blinkbox.com/127.0.0.1
address=/abc.com/127.0.0.1
address=/fox.com/127.0.0.1
address=/theplatform.com/127.0.0.1
address=/nbc.com/127.0.0.1
address=/nbcuni.com/127.0.0.1
address=/ip2location.com/127.0.0.1
address=/pbs.org/127.0.0.1
address=/warnerbros.com/127.0.0.1
address=/southpark.cc.com/127.0.0.1
address=/cbs.com/127.0.0.1
address=/brightcove.com/127.0.0.1
address=/cwtv.com/127.0.0.1
address=/spike.com/127.0.0.1
address=/go.com/127.0.0.1
address=/mtv.com/127.0.0.1
address=/mtvnservices.com/127.0.0.1
address=/playstation.net/127.0.0.1
address=/uplynk.com/127.0.0.1
address=/maxmind.com/127.0.0.1
address=/disney.com/127.0.0.1
address=/disneyjunior.com/127.0.0.1
address=/xboxlive.com/127.0.0.1
address=/lovefilm.com/127.0.0.1
address=/turner.com/127.0.0.1
address=/amctv.com/127.0.0.1
address=/sho.com/127.0.0.1
address=/mog.com/127.0.0.1
address=/wdtvlive.com/127.0.0.1
address=/beinsportsconnect.tv/127.0.0.1
address=/beinsportsconnect.net/127.0.0.1
address=/fig.bbc.co.uk/127.0.0.1
address=/open.live.bbc.co.uk/127.0.0.1
address=/sa.bbc.co.uk/127.0.0.1
address=/www.bbc.co.uk/127.0.0.1
address=/crunchyroll.com/127.0.0.1
address=/ifconfig.co/127.0.0.1
address=/omtrdc.net/127.0.0.1
address=/sling.com/127.0.0.1
address=/movetv.com/127.0.0.1
address=/happyon.jp/127.0.0.1
address=/abema.tv/127.0.0.1
address=/hulu.jp/127.0.0.1
address=/optus.com.au/127.0.0.1
address=/optusnet.com.au/127.0.0.1
address=/gamer.com.tw/127.0.0.1
address=/bahamut.com.tw/127.0.0.1
address=/hinet.net/127.0.0.1
开启开机自启
systemctl enable dnsmasq
重启一下dnsmasq
systemctl restart dnsmasq
测试
yum install -y bind-utils
执行nslookup ip.sb 127.0.0.1查看是否能正常解析出来自己vps的IP地址,可以的话就说明成功。
搭建sniproxy
上面把各种的流媒体网址都解析成自己的,比如访问http://ip.sb 就访问自己的vps的80端口,https:// 就是自己vps的443端口,sniproxy来监听这两个端口,收到数据后原封不动的把你的数据发送到你访问的网址,代替你访问,然后把反馈的数据再反馈给你,简单来说就是代理。
安装
直接安装
wget https://github.com/myxuchangbin/dnsmasq_sniproxy_install/raw/master/sniproxy/sniproxy-0.6.0.el7.x86_64.rpm
yum install -y sniproxy-0.6.0.el7.x86_64.rpm
安装成功的结尾信息大致如下
Installed:
sniproxy.x86_64 0:0.6.0+git.10.g822bb80-1.el7Dependency Installed:
libev.x86_64 0:4.15-7.el7 udns.x86_64 0:0.4-3.el7Complete!
安装成功就好,如果不成功就要编译安装。
编译安装
安装依赖
yum install autoconf automake curl gettext-devel libev-devel pcre-devel perl pkgconfig rpm-build udns-devel
从github下载源码
git clone https://github.com/dlundquist/sniproxy.git
编译
# 进入目录sniproxy
cd sniproxy
# 编译
./autogen.sh && ./configure && make dist
# 最后执行
rpmbuild --define "_sourcedir `pwd`" -ba redhat/sniproxy.spec
即可编译成功
进入编译的目录下cd ../rpmbuild/RPMS
一般只有一个文件夹,也就是自己这个vps的架构,进去后会有两个文件,安装那个名字没有debug的文件
安装(命令中的版本号可能会变化):
yum install -y sniproxy-0.6.0+git.10.g822bb80-1.el7.x86_64.rpm
即可。
sniproxy配置文件
在根目录的etc目录下创建一个文件sniproxy.conf,编辑他,填写内容如下(内容同参考开头参考资料)
user root
pidfile /var/tmp/sniproxy.pid
resolver {
nameserver 8.8.8.8
nameserver 8.8.4.4
mode ipv4_only
}
listener 0.0.0.0:80 {
proto http
}
listener 0.0.0.0:443 {
proto tls
}
table {
.*akadns\.net$ *
.*akam\.net$ *
.*akamai\.com$ *
.*akamai\.net$ *
.*akamaiedge\.net$ *
.*akamaihd\.net$ *
.*akamaistream\.net$ *
.*akamaitech\.net$ *
.*akamaitechnologies\.com$ *
.*akamaitechnologies\.fr$ *
.*akamaized\.net$ *
.*edgekey\.net$ *
.*edgesuite\.net$ *
.*srip\.net$ *
.*footprint\.net$ *
.*level3\.net$ *
.*llnwd\.net$ *
.*edgecastcdn\.net$ *
.*cloudfront\.net$ *
.*netflix\.com$ *
.*netflix\.net$ *
.*nflximg\.net$ *
.*nflxvideo\.net$ *
.*nflxso\.net$ *
.*nflxext\.com$ *
.*hulu\.com$ *
.*huluim\.com$ *
.*hbonow\.com$ *
.*hbogo\.com$ *
.*hbo\.com$ *
.*amazon\.com$ *
.*amazon\.co\.uk$ *
.*amazonvideo\.com$ *
.*crackle\.com$ *
.*pandora\.com$ *
.*vudu\.com$ *
.*blinkbox\.com$ *
.*abc\.com$ *
.*fox\.com$ *
.*theplatform\.com$ *
.*nbc\.com$ *
.*nbcuni\.com$ *
.*ip2location\.com$ *
.*pbs\.org$ *
.*warnerbros\.com$ *
.*southpark\.cc\.com$ *
.*cbs\.com$ *
.*brightcove\.com$ *
.*cwtv\.com$ *
.*spike\.com$ *
.*go\.com$ *
.*mtv\.com$ *
.*mtvnservices\.com$ *
.*playstation\.net$ *
.*uplynk\.com$ *
.*maxmind\.com$ *
.*disney\.com$ *
.*disneyjunior\.com$ *
.*xboxlive\.com$ *
.*lovefilm\.com$ *
.*turner\.com$ *
.*amctv\.com$ *
.*sho\.com$ *
.*mog\.com$ *
.*wdtvlive\.com$ *
.*beinsportsconnect\.tv$ *
.*beinsportsconnect\.net$ *
.*fig\.bbc\.co\.uk$ *
.*open\.live\.bbc\.co\.uk$ *
.*sa\.bbc\.co\.uk$ *
.*www\.bbc\.co\.uk$ *
.*crunchyroll\.com$ *
.*ifconfig\.co$ *
.*omtrdc\.net$ *
.*sling\.com$ *
.*movetv\.com$ *
.*happyon\.jp$ *
.*abema\.tv$ *
.*hulu\.jp$ *
.*optus\.com\.au$ *
.*optusnet\.com\.au$ *
.*gamer\.com\.tw$ *
.*bahamut\.com\.tw$ *
.*hinet\.net$ *
}
然后启动即可。
sniproxy -c /etc/sniproxy.conf
此时这个vps的ip就是一个解锁dns了。