DNS
Posted 无限剑
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DNS相关的知识,希望对你有一定的参考价值。
DNS服务器
正向解析:将域名解析成IP地址
反向解析:将IP地址解析成域名
yum install bind
named-checkconf
##############################################################################
vi /etc/named.conf
192.168.55.128 和 any
vi /etc/named.rfc1912.zones
zone "dd.com" IN {
type master;
file "dd.com.zone";
allow-update { none; };
};
zone "55.168.192.in-addr.arpa" IN {
type master;
file "dd.com.local";
allow-update { none; };
};
cd /var/named
cp -p named.localhost dd.com.zone
cp -p named.loopback dd.com.local
$TTL 1D
@ IN SOA dns.dd.com. root.dd.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.dd.com.
dns A 192.168.55.128
www A 192.168.55.128
ftp A 192.168.55.128
$TTL 1D
@ IN SOA dns.dd.com. root.dd.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.dd.com.
128 PTR dns.dd.com.
128 PTR www.dd.com.
128 PTR ftp.dd.com.
systemctl start named
vi /etc/resolv.conf
全删加
nameserver 192.168.55.128
##############################################################################
##############################################################################
vi /etc/named.conf
any 和 any
vi /etc/named.rfc1912.zones
zone "dd.com" IN {
type master;
file "dd.com.zone";
allow-update { none; };
};
zone "55.168.192.in-addr.arpa" IN {
type master;
file "dd.com.local";
allow-update { none; };
};
cd /var/named
cp -p named.localhost dd.com.zone
cp -p named.loopback dd.com.local
$TTL 1D
@ IN SOA dns.dd.com. root.dd.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.dd.com.
dns A 192.168.55.1
www A 192.168.55.10
ftp A 192.168.55.20
$TTL 1D
@ IN SOA dns.dd.com. root.dd.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.dd.com.
1 PTR dns.dd.com.
10 PTR www.dd.com.
20 PTR ftp.dd.com.
systemctl start named
vi /etc/resolv.conf
全删加
nameserver 192.168.55.1
nameserver 192.168.55.10
nameserver 192.168.55.20
##############################################################################
DNS服务器分离解析析
分离解析的DNS服务器
#主内外网卡
vi /etc/named.conf
any any
跳到52行,将下面四行删掉
zone "." IN {
type hint;
file "named.ca";
};
named-checkconf
vi /etc/named.rfc1912.zones
#zone开头的全部删掉
view "LAN" {
match-clients { 192.168.55.128/24; };
zone "dd.com" IN {
type master;
file "dd.com.zone.lan";
};
};
view "WAN" {
match-clients { any; };
zone "dd.com" IN {
type master;
file "dd.com.zone.wan";
};
};
named-checkconf
cd /var/named
cp -p named.localhost dd.com.zone.lan
cp -p named.localhost dd.com.zone.wan
vi dd.com.zone.lan
$TTL 1D
@ IN SOA dns.dd.com. root.dd.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.dd.com.
www A 192.168.55.128
dns A 192.168.55.128
vi dd.com.zone.wan
$TTL 1D
@ IN SOA dns.dd.com. root.dd.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.dd.com.
www A 192.168.1.128
dns A 192.168.55.128
named-checkconf
start named
win7 外网一台win7
##############################################################################
DNS主从同步服务器
named-checkconf
#主
vi /etc/named.conf
192.168.55.128 和 any
vi /etc/named.rfc1912.zones
zone "dd.com" IN {
type master;
file "dd.com.zone";
allow-update { 192.168.55.132; };
also-notify { 192.168.55.132; };
};
zone "55.168.192.in-addr.arpa" IN {
type master;
file "dd.com.local";
allow-update { 192.168.55.132; };
also-notify { 192.168.55.132; };
};
cd /var/named
cp -p named.localhost dd.com.zone
cp -p named.loopback dd.com.local
vi dd.com.zone
$TTL 1D
@ IN SOA dns.dd.com. root.dd.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.dd.com.
dns A 192.168.55.128
www A 192.168.55.128
ftp A 192.168.55.128
vi dd.com.local
$TTL 1D
@ IN SOA dns.dd.com. root.dd.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.dd.com.
128 PTR dns.dd.com.
128 PTR www.dd.com.
128 PTR ftp.dd.com.
systemctl start named
vi /etc/resolv.conf
全删加
nameserver 192.168.55.128
##############################################################################
#从
vi /etc/named.conf
192.168.55.132 和 any
vi /etc/named.rfc1912.zones
zone "dd.com" IN {
type slave;
masters { 192.168.55.128; };
file "slaves/dd.com.zone";
allow-notify { 192.168.55.128; };
};
zone "55.168.192.in-addr.arpa" IN {
type slave;
masters { 192.168.55.128; };
file "slaves/dd.com.local";
allow-notify { 192.168.55.128; };
};
vi /etc/resolv.conf
nameserver 192.168.55.128
systemctl start named
cd /var/named/slaves/ #查看是否同步了主的dd.com.zone
ls
以上是关于DNS的主要内容,如果未能解决你的问题,请参考以下文章
DNS简介DNS工作原理DNS正反向解析的搭建DNS主从备份DNS子域创建