liunx服务使用(DNS服务器)

看着百度啦 搜狐了各大门户网站,通过域名就可以访问到,但是实际情上访问的是IP地址,IP转化成为的域名他们俩个绑定在一起了,具体的是怎么实现的?看看DNS域名服务器吧。



DNS(域名解析服务器)

bind-9.3.6-20.P1.el5.i386.rpm 主程序

bind-chroot-9.3.6-20.P1.el5.i386.rpm chroot的安全

caching-nameserver-9.3.6-20.P1.el5.i386.rpm 提供配置文件


启动服务:

service named restart

端口:

53


主配置文件 2个

[root@localhost etc]# vim /var/named/chroot/etc/named.

named.caching-nameserver.conf named.rfc1912.zones


----------------------------------------------------------

正向解析

vim /etc/named.caching-nameserver.conf

options {

listen-on port 53 { any; }; 监听

directory "/var/named"; 指定文件夹

allow-query { any; }; 允许查询

allow-query-cache { any; }; 允许查询缓存

};

view localhost_resolver {

match-clients { any; }; 允许客户端访问

match-destinations { any; }; 目标匹配

recursion yes; 递归查询开始

include "/etc/named.rfc1912.zones"; 指定这个文件 成功以后自动添加到/etc/named.rfc1912.zones文件里去

};


定义域名

2.vim /etc/named.rfc1912.zones

zone "uplooking.com" IN {

type master;

file "uplooking.com.zone";

};


创建对应文件


3.cd /var/named/chroot/var/named/

touch uplooking.com.zone

chown :named uplooking.com.zone

chmod 640 uplooking.com.zone



-------------------------

$TTL路由跳数 86400妙


@(调用上面zone "uplooking.com" IN {) IN 授权给 SOA dns。

IN NS

------------------------

vim uplooking.com.zone

$TTL 86400

@ IN SOA dns.uplooking.com. root ( 20121222 3H 15M 1W 1D )

IN NS(nameservice) dns.uplooking.com.

dns IN A 192.168.1.2

www IN A 192.168.1.2


------------------------------

启动服务:

service named restart

测试

DNS指向/etc/resolv.conf

nameserver 192.168.1.2


host www.uplooking.com

nslookup www.uplooking.com


-------------------------------


邮箱的解析

IN MX 5 mail.uplooking.com.

mail IN(因特网) A(a记录) 192.168.1.2

web IN CNAME ftp.uplooking.com.

ftp IN A 192.168.1.2

直接写域名

@ IN A 192.168.1.2

* IN A 192.168.1.2


动态的解析

$GENERATE 1-254 stu$ IN A 192.168.1.$



**********************************************************************************************************************

$TTL 86400

@ IN SOA dns.uplooking.com. root ( 20121222 3H 15M 1W 1D )

IN NS dns.uplooking.com.

dns IN A 192.168.1.2

IN MX 5 mail.uplooking.com.

mail IN A 192.168.1.2

web IN CNAME ftp.uplooking.com.

ftp IN A 192.168.1.2

;@ IN A 192.168.1.2

;* IN A 192.168.1.2

;$GENERATE 1-254 stu$ IN A 192.168.1.$

www 5(承受的程度) IN A 192.168.1.133

www 3 IN A 192.168.1.113 轮转负载均衡8.1.21 Bcast

www 2 IN A 192.168.1.110

****************************************************************************************************************


反向解析

vim /etc/named.rfc1912.zones

zone "1.168.192.in-addr.arpa" IN {

type master;

file "163.com.arpa";

};


cd /var/named/chroot/var/named/

touch 163.com.arpa

chown :named 163.com.arpa

chmod 640 163.com.arpa

vim 163.com.arpacache_peer 192.168.1.113 parent 80 0 round-robin

cache_peer 192.168.1.111 parent 80 0 round-robin



$TTL 86400

@ IN SOA dns.163.com. root ( 20121223 3H 15M 1W 1D )

IN NS dns.163.com.

2 IN PTR dns.163.com.

2 IN PTR www.163.com.


测试:

host 192.168.1.2


-------------------------------


主从服务器

主:

vim /etc/named.rfc1912.zones

zone "youku.com" IN {

type master;

file "youku.com.zone";

allow-transfer { 192.168.1.211; };

};


cd /var/named/chroot/var/named/

touch youku.com.zone

chown :named youku.com.zone

chmod 640 yoku.com.zone

vim youku.com.zone

$TTL 86400

@ IN SOA dns.youku.com. root ( 20121222 3H 15M 1W 1D )

IN NS dns.youku.com.

dns IN A 192.168.1.2

www IN A 192.168.1.2


从:

vim /etc/named.caching-nameserver.conf

listen-on port 53 { any; };

allow-query { any; };

allow-query-cache { any; };

match-clients { any; };

match-destinations { any; };


vim /etc/named.rfc1912.zones

zone "youku.com" IN {

type slave;

file "slaves/youku.com.zone";

masters { 192.168.1.2; };

};


service named restart(重启后获得域解析文件)

vim /etc/resolv.conf

nameserver 192.168.1.113 主DNS

nameserver 192.168.1.101 从DNS



host www.youku.com


-------------------------------------------


同步版本

vim youku.com.zone

$TTL 86400

@ IN SOA dns1.youku.com. root ( 20121222 3H 15M 1W 1D )

IN NS dns1.youku.com.

IN NS dns2.youku.com.

dns1 IN A 192.168.1.2

dns2 IN A 192.168.1.211

www IN A 192.168.1.2


service named reload


-----------------------

事物签名(key) (加密方式) (字节) (算法)

dnssec-keygen -a hmac-md5 -b 128 -n HOST zhb.

主:

vim /etc/named.rfc1912.zones

key zhb {

algorithm hmac-md5;

secret "Iw0SmCmxl3z24g63GulxhA==";

};


zone "youku.com" IN {

type master;

file "youku.com.zone";

allow-transfer { key zhb; };

};


从:

vim /etc/named.rfc1912.zones

key zhb {

algorithm hmac-md5;

secret "Iw0SmCmxl3z24g63GulxhA==";

};


zone "youku.com" IN {

type slave;

file "slaves/youku.com.zone";

masters { 192.168.1.2 key zhb; };

};


----------------------------------------------

DNS转发

vim/var/named/chroot/etc/named.caching-nameserver.conf


转发:

ptions {

allow-query { 192.168.1.0/24; };

forward first;

forwarders {61.175.153.129;};

};


allow-query-cache { any; };

forward only;

forwarders {192.168.1.254;};



---------------------------------------------------------------------------

子域授权

父域:


zone "tudou.com" IN {

type master;

file "tudou.com.zone";

};



$TTL 86400

@ IN SOA dns.tudou.com. root ( 20121231 3H 15M 1W 1D )

IN NS dns.tudou.com.

dns IN A 192.168.1.2

music.tudou.com. IN NS dns.music.tudou.com.

dns.music.tudou.com. IN A 192.168.1.211

www IN A 192.168.1.2


子域:

zone "music.tudou.com" IN {

type master;

file "music.tudou.com.zone";

};


$TTL 86400

@ IN SOA dns.music.tudou.com. root ( 20121223 3H 15M 1W 1D )

IN NS dns.music.tudou.com.

dns IN A 192.168.1.211

www IN A 192.168.1.211


------------------------------------------------------------

视图(智能DNS)


httpd: 192.168.1.71 192.168.1.133 192.168.1.123

cnctelother

client:192.168.1.169 192.168.1.168 192.168.1.248

cnctelother

DNS:192.168.1.2


1. vim /etc/named.caching-nameserver.conf

acl cnc { 192.168.1.169; };

acl tel { 192.168.1.16cnc; };

recursion yes;8; };

acl other { 192.168.1.248; };


view cncnet {

match-clients {

include “/etc/12306cnc”;

};

view telnet {

match-clients { tel; };

recursion yes;

include “/etc/12306tel”;

};

view othernet {

match-clients { other; };

recursion yes;

include “/etc/12306other”;

};


2.cd /var/named/chroot/etc/

touch 12306cnc 12306tel 12306other


vim 12306cnc

zone "12306.com" IN {

type master;

file "12306.com.cnc";

};


vim 12306other

zone "12306.com" IN {

type master;

file "12306.com.other";

};

vim 12306tel

zone "12306.com" IN {

type master;

file "12306.com.tel";

};


3.cd /var/named/chroot/var/named/

vim 12306.com.cnc

$TTL 86400

@ IN SOA dns.12306.com. root ( 20121223 3H 15M 1W 1D )

IN NS dns.12306.com.

dns IN A 192.168.1.2

www IN A 192.168.1.71


vim 12306.com.other

$TTL 86400

@ IN SOA dns.12306.com. root ( 20121223 3H 15M 1W 1D )

IN NS dns.12306.com.

dns IN A 192.168.1.2

www IN A 192.168.1.123


vim 12306.com.tel

$TTL 86400

@ IN SOA dns.12306.com. root ( 20121223 3H 15M 1W 1D )

IN NS dns.12306.com.

dns IN A 192.168.1.2

www IN A 192.168.1.133


chmod 640 12306*

chown :named 12306*

service named restart




你可能感兴趣的:(service,百度,配置文件,IP地址,域名服务器)