参考:https://serverfault.com/questions/41064/whats-the-command-line-utility-in-windows-to-do-a-reverse-dns-look-up
nslookup -type=ptr 14.251.177.38 8.8.8.8
服务器: dns.google
Address: 8.8.8.8
非权威应答:
38.177.251.14.in-addr.arpa name = static.vnpt.vn
参考:https://serverfault.com/questions/41064/whats-the-command-line-utility-in-windows-to-do-a-reverse-dns-look-up
nslookup -type=ptr 14.251.177.38 8.8.8.8
服务器: dns.google
Address: 8.8.8.8
非权威应答:
38.177.251.14.in-addr.arpa name = static.vnpt.vn
https://blog.51cto.com/91xueit/1130610
实战目的:
ü 在内网,用户习惯使用计算机名而不是计算机全名访问资源,你需要配置客户端,解析计算机名时在计算机名称后添加一个DNS后缀构造一个域名,然后通过DNS服务器解析该计算机的IP地址。
企业环境:
在微软河北企业护航中心网络有一个内部网络,通过ADSL连接到Internet。在内网有一个域环境。Win2k3计算机是工作组中的计算机。使用内网的计算机用户访问内网服务器时,习惯使用服务器名,而不习惯使用服务器全名,网络管理员希望配置客户机能够通过DNS服务器解析服务器名。
在工作组中的计算机win2k3上进行名称解析测试。将IP地址设置成自动获得,在命令提示符下输入ipconfig /renew重新刷新地址租约,在输入ipconfig /all可以看到由DHCP服务器配置DNS后缀搜索列表。
配置:
ping Research服务器的计算机名称,注意看解析到的结果是research.ess.com域名对应的IP地址。该解析结果是DNS服务器返回的。
https://www.zhihu.com/question/36891472
一个域名可以解析出几个IP地址,例如在访问www.163.com时,抓包得到的DNS响应包中有2个IP地址:221.229.167.47和58.220.39.91,
虽然DNS解析得到了多个IP,但是大多数软件只会使用第一个IP地址,这是什么原因?
TCP/IP网络通信是基于IP地址的,当要访问的服务器地址是域名时,就需要先把域名解析成IP地址。在TCP/IP API中有一个叫gethostbyname的函数,负责把域名解析成IP地址。 函数的原型定义如下,参数name就是要解析的域名。struct hostent *gethostbyname(const char *name);
struct hostent {
char *h_name; /* official name of host */
char **h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char **h_addr_list; /* list of addresses */
}
#define h_addr h_addr_list[0] /* for backward compatibility */
结构体中的h_addr_list是一个数组,用于存放解析出的多个IP地址,但很少有程序员会去考虑多个IP地址的问题,通常直接使用宏h_addr来获取IP地址,也就是第一个IP地址。
[popexizhi: 这样看推断是客户端完成的,但记得好像操作系统也可以设置,但没有找到对应介绍,mark一下]
logging
{
channel default-log {
file "/var/log/named_default.log" versions 10 size 200m;
severity info;
print-time yes;
};
channel lamer-log {
file"/var/log/named_lamer.log" versions 3 size 100m;
severity info;
print-severity yes;
print-time yes;
print-category yes;
};
channel query-log {
file "/var/log/named_query.log" versions 10 size 1000m;
severity info;
print-time yes;
};
channel security-log {
file"/var/log/named_security.log" versions 3 size 100m;
severity info;
print-severity yes;
print-time yes;
print-category yes;
};
category lame-servers { lamer-log; };
category security{ security-log;}; category queries { query-log;};
category default { default-log;};
};
sudo /etc/init.d/named restart
vim /etc/name.d
...
112 zone "gfbvy.ws" IN {
113 type master;
114 file "fwd.gfbvy.db";
115 };
...
vim /var/fwd.gfbvy.db
1 $TTL 86400
2 ;@ IN SOA gfbvy.ws.
4 2016042112 ;Serial
5 3600 ;Refresh
6 1800 ;Retry
7 604800 ;Expire
8 43200 ;Minimum TTL
9 )
10
11 ;Name Server Information
12 @ 2d IN NS gfbvy.ws.
13 ;IP address of Name Server
14 @ 3600 IN A 220.181.119.37
vim /var/fwd.gfbvy.db
1 $TTL 86400 2 ;@ IN SOA gfbvy.ws. ;( [err] 1 no has root. err log" _default/gfbvy.ws/IN: unexpected end of input" 3 @ IN SOA gfbvy.ws. root.gfbvy.ws. ( 4 2016042112 ;Serial 5 3600 ;Refresh 6 1800 ;Retry 7 604800 ;Expire 8 43200 ;Minimum TTL 9 ) 10 11 ;Name Server Information ;[err] 2 must has , err log "_default/gfbvy.ws/IN: bad zone" 12 @ 2d IN NS gfbvy.ws. 13 ;IP address of Name Server 14 @ 3600 IN A 220.181.119.37 ~
:~/test/install_1/install$ nslookup -q=AAAA google.com 8.8.8.8
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: google.com
Address: 2404:6800:4005:801::200e
Bind是一款开放源码的DNS服务器软件,Bind由美国加州大学Berkeley分校开发和维护的,全名为Berkeley Internet Name Domain它是目前世界上使用最为广泛的DNS服务器软件。
1
|
yum update
|
1
|
yum install bind bind-utils
|
1
2
|
systemctl enable named
systemctl start named
|
1
|
systemctl status named
|
1
|
named -v
|
1
|
vim /etc/named.conf
|
1
2
|
#listen-on port 53 { 127.0.0.1; };
#listen-on-v6 port 53 { ::1; };
|
1
|
allow-query { localhost;192.168.10.0/24; };
|
1
|
allow-transfer { your_slave_server_ip; };
|
1
|
vim /etc/named.conf
|
1
2
3
4
5
|
zone "linux.local" IN {
type master;
file "fwd.linux.local.db";
allow-update { none; };
};
|
1
2
3
4
5
|
zone "10.168.192.in-addr.arpa" IN {
type master;
file "10.168.192.db";
allow-update { none; };
};
|
1
|
vim /var/named/fwd.linux.local.db
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
$TTL 86400
@ IN SOA primary.linux.local. root.linux.local. (
2016042112 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
43200 ;Minimum TTL
)
;Name Server Information
@ IN NS primary.linux.local.
;IP address of Name Server
primary IN A 192.168.10.173
;Mail exchanger
linux.local. IN MX 10 mail.linux.local.
;A - Record HostName To Ip Address
www IN A 192.168.10.176
mail IN A 192.168.10.177
;CNAME record
ftp IN CNAME www.linux.local.
|
1
2
3
4
|
A – A record
NS – Name Server
MX – Mail for Exchange
CN – Canonical Name
|
1
|
vim /var/named/10.168.192.db
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
$TTL 86400
@ IN SOA primary.linux.local. root.linux.local. (
2014112511 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
;Name Server Information
@ IN NS primary.linux.local.
;Reverse lookup for Name Server
8 IN PTR primary.linux.local.
;PTR Record IP address to HostName
100 IN PTR www.linux.local.
150 IN PTR mail.linux.local.
|
1
2
|
chmod 777 /var/named/fwd.linux.local.db
chmod 777 /var/named/10.168.192.db
|
1
|
systemctl restart named.service
|
1
|
nameserver primary_dns_server_ip
|
1
|
dig www.linux.local
|
1
|
dig -x client_server_ip
|