lersh / lersh.github.io

蓝精灵的大森林
7 stars 0 forks source link

shadowsocks转发pdnsd解决dns污染的方案 #6

Open lersh opened 8 years ago

lersh commented 8 years ago

原本shadowsocks可以通过ss-tunnel来转发udp请求来解决dns污染问题,但是我们公司的网络比较奇葩,会不定时的阻断非认证服务器(因为查询公司的dns是没问题的)的udp请求。具体现象就是会不定期的dns解析失败,自己的vps上搭建了dnsmasq也不行,时灵时不灵,不灵的时候通过墙外的vps去查询是可用的,但是在公司里就不行,ss-tunnel转发也不行。这抽风的网络……无语……

因此我想到了用tcp转发dns请求,但是openwrt版的shadowsocks没有这个功能,于是曲线救国,用pdnsd采用tcp到opendns(8.8.8.8实测不行会被阻断)去解析,再用ss-redir来加密这个tcp,实现防污染抗感染的目的(因为纯tcp解析现在也不安全了)

global {

        perm_cache=1024;

        cache_dir="/var/pdnsd";

#       pid_file = /var/run/pdnsd.pid;

        run_as="nobody";

        server_ip = 127.0.0.1;  # Use eth0 here if you want to allow other

                                # machines on your network to query pdnsd.

        server_port=5300;      #监听5300端口

        status_ctl = on;

#       paranoid=on;       # This option reduces the chance of cache poisoning

                           # but may make pdnsd less efficient, unfortunately.

        query_method=tcp_only;  #强制tcp解析dos

        min_ttl=15m;       # Retain cached entries at least 15 minutes.

        max_ttl=1w;        # One week.

        timeout=10;        # Global timeout option (10 seconds).

        neg_domain_pol=on;

        udpbufsize=1024;   # Upper limit on the size of UDP messages.

}

server {

        label = "opendns";

        ip = 208.67.222.222, 208.67.220.220;

        port = 5353;

        timeout = 4;

        uptest = none;            # Test availability using ICMP echo requests.

}

然后将opendns的ip加入upset,因为我们配置了gfwlist的upset走shadowsocks

ipset add gfwlist 208.67.222.222
ipset add gfwlist 208.67.220.220

最后关掉shadowsocks的ss-tunnel转发即可

gonejack commented 8 years ago

话说Google的DNS + TCP + ss-redir 转发不可以吗,为什么会被阻断?

jack338c commented 8 years ago

碰到了和楼主一样的问题,想用8.8.8.8难啊