ubuntu-利用pdnsd-TCP方式获取IP-拒绝DNS污染

那,自从国内技术出现了DNS污染问题呢,时常导致很多国外网站访问不正常,所以通过参考一些博客所属避免DNS污染的方法,决定搭建一个Ubuntu JeOS下的DNS缓存服务器,该服务器利用TCP方式获取IP解析,这样就可以避免DNS污染问题了。

首先,进入root权限:

sudo –i

然后输入用户名对应的密码,进入root权限命令行。

利用以下指令安装所需软件Pdnsd:

apt-get install pdnsd

安装后选择OK,Manual手动配置文件。

vim /etc/pdnsd.conf

进入VIM编辑配置文件,按i进入编辑模式,修改如下代码进去(主要注意global和server下的内容,其他的默认即可):

global {
	perm_cache=1024;
	cache_dir="/var/cache/pdnsd";
	run_as="pdnsd";
	server_ip = eth0;  // Use eth0 here if you want to allow other
				// machines on your network to query pdnsd.
	status_ctl = on;
  	paranoid=on;
  	query_method=tcp_only;	// pdnsd must be compiled with tcp
				// query support for this to work.
	min_ttl=1d;       // Retain cached entries at least 15 minutes.
	max_ttl=1w;	   // One week.
	timeout=10;        // Global timeout option (10 seconds).

        // Don't enable if you don't recurse yourself, can lead to problems
        // delegation_only="com","net";
}

/* with status_ctl=on and resolvconf installed, this will work out from the box
   this is the recommended setup for mobile machines */

// This section is meant for resolving from root servers.
server {
	label = "root-servers";
	root_server=on;
	ip = 8.8.8.8,208.67.222.222,208.67.220.220;
	timeout = 5;
	uptest = query;
	interval = 30m;      // Test every half hour.
	ping_timeout = 300;  // 30 seconds.
	purge_cache = off;
	exclude = .localdomain;
	policy = included;
	preset = off;
}

source {
	owner=localhost;
//	serve_aliases=on;
	file="/etc/hosts";
}

rr {
	name=localhost;
	reverse=on;
	a=127.0.0.1;
	owner=localhost;
	soa=localhost,root.localhost,42,86400,900,86400,86400;
}

/*
neg {
	name=doubleclick.net;
	types=domain;   // This will also block xxx.doubleclick.net, etc.
}
*/

/*
neg {
	name=bad.server.com;   // Badly behaved server you don't want to connect to.
	types=A,AAAA;
}
*/

/* vim:set ft=c: */

编辑完毕后按ESC退出编辑模式,shift+:呼出命令行,输入wq!保存退出。

下面编辑本机DNS服务器

vim resolv.conf

进入VIM编辑配置文件,按i进入编辑模式,清空所有内容,写入以下内容:

nameserver 127.0.0.1

编辑完毕后按ESC退出编辑模式,shift+:呼出命令行,输入wq!保存退出。

下面修改START_DAEMON部分

vim /etc/default/pdnsd

进入VIM编辑配置文件,按i进入编辑模式,修改代码:

START_DAEMON=no为START_DAEMON=yes

编辑完毕后按ESC退出编辑模式,shift+:呼出命令行,输入wq!保存退出。

重启pdnsd

/etc/init.d/pdnsd restart

这样之后,就可以让别的电脑用你的linux的IP作为DNS服务器来避免DNS污染了。

现在的问题是这服务器我搭起来开始正常,后来就不正常了,dig提示connection timed out; no servers could be reached,唏嘘……

posted @ 2014-12-14 15:32  大漠银狐  阅读(1319)  评论(0编辑  收藏  举报