DNS劫持

DNS是什么呢,是全世界所有的域名对应的ip解析的服务器,输入一个域名可以解析到ip,输入ip可以解析到域名,比较常用的dns地址114.114.114.114,假如一个人的电脑配置的dns地址不对,通过域名来访问服务器web应用的时候就解析不到主机,资源就获取不到了,既然dns是一台服务器,那么自己的电脑就可以搭建DNS服务器了,linux下搭建dns服务器的有bing9,下面是主要配置的参数:

文件名:/etc/bind/named.conf.options

options {
	directory "/var/cache/bind";

	 forwarders {
	 	114.114.114.114;
	 };

	dnssec-validation auto;

	auth-nxdomain no;    # conform to RFC1035
	listen-on-v6 { any; };
};

上面的那个forwarders意思是本地DNS没解析到的去中国区通用的DNS服务器解析(这地方可以想象);

文件名:/etc/bind/named.conf.default-zones

// prime the server with knowledge of the root servers
zone "." {
	type hint;
	file "/etc/bind/db.root";
};

// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912

zone "localhost" {
	type master;
	file "/etc/bind/db.local";
};

zone "127.in-addr.arpa" {
	type master;
	file "/etc/bind/db.127";
};

zone "0.in-addr.arpa" {
	type master;
	file "/etc/bind/db.0";
};

zone "255.in-addr.arpa" {
	type master;
	file "/etc/bind/db.255";
};

zone "demo.com" {
	type master;
	file "/etc/bind/db.1";
};

zone "127.0.0.1.in-addr.arpa" {
	type master;
	file "/etc/bind/db.2";
};

其中倒数第二个是正向解析,就三通过域名解析到ip,最后一个是反向解析,通过ip解析到域名;

正向解析文件配置:/etc/bind/db.1

; BIND reverse data file for empty rfc1918 zone
;
; DO NOT EDIT THIS FILE - it is used for multiple zones.
; Instead, copy it, edit named.conf, and use that copy.
;
$TTL	86400
@	IN	SOA	dns.demo.com. root.demo.com. (
			      1		; Serial
			 604800		; Refresh
			  86400		; Retry
			2419200		; Expire
			  86400 )	; Negative Cache TTL
;
@	IN	NS	dns.demo.com.
*	IN	A	127.0.0.1
@	IN	A	127.0.0.1

反向解析文件配置:/etc/bind/db.2

; BIND reverse data file for empty rfc1918 zone
;
; DO NOT EDIT THIS FILE - it is used for multiple zones.
; Instead, copy it, edit named.conf, and use that copy.
;
$TTL	86400
@	IN	SOA	dns.demo.com. root.demo.com. (
			      1		; Serial
			 604800		; Refresh
			  86400		; Retry
			2419200		; Expire
			  86400 )	; Negative Cache TTL
;
@	IN	NS	dns.demo.com.
1	PTR		www.demo.com.

 上面标签什么意思,文本太长,不好解释;

这上面DNS服务器搭建之后,同过指令可以查看正向与反向地址,正向地址如下:

root@huangxudong-X456UR:/etc/bind# nslookup www.demo.com
Server:		127.0.0.1
Address:	127.0.0.1#53

Name:	www.demo.com
Address: 127.0.0.1

现在通过浏览器看看什么情况,本地已经搭建了tomcat环境,端口8080,80端口已经被占用;

DNS劫持_第1张图片

假设在服务器上搭建一个DNS服务器,将这个DNS服务器的地址装到对象那里,对象可以正常上网,当对象上www.demo.com的时候跳到自定义的网页了,linux设置dns是 /etc/resolv.conf里面写DNS地址;

 

你可能感兴趣的:(安全)