nslookup命令
功能说明
nslookup命令,在Windows、Linux下常用的网络命令,可用来诊断域名系统(DNS)的信息。
Centos7,由于使用最小安装,默认没有带该命令,下面是安装命令演示:
[root@c7 ~]# nslookup #提示没有找到命令 -bash: nslookup: 未找到命令 [root@c7 ~]# yum provides */nslookup #查询nslookup使用哪个软件包 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.neusoft.edu.cn * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.tuna.tsinghua.edu.cn #查询到是使用bind-utils软件包 32:bind-utils-9.9.4-29.el7.x86_64 : Utilities for querying DNS name servers 源 :base 匹配来源: 文件名 :/usr/bin/nslookup [root@c7 ~]# yum -y install bind-utils #安装该bind-utils软件包 [root@c7 ~]# nslookup > www.baidu.com Server: 219.141.140.10 Address: 219.141.140.10#53 Non-authoritative answer: www.baidu.com canonical name = www.a.shifen.com. Name: www.a.shifen.com Address: 220.181.112.244 Name: www.a.shifen.com Address: 220.181.111.188 > |
示例
截取其中服务器的IP地址
[root@rsync01 shell]# nslookup z.cn Server: 114.114.114.114 Address: 114.114.114.114#53 Non-authoritative answer: Name: z.cn Address: 54.222.60.252 [root@rsync01 shell]# nslookup z.cn | tail -2 | head -1 | awk '{print $2}' 54.222.60.252 [root@rsync01 shell]# |
转载于:https://blog.51cto.com/zhaodongwei/1760888