跳至主要內容

nslookup-域名获取IP

pptg小于 1 分钟

在公司同时使用内外网时,需要添加公司的内网路由(主要是访问邮箱、OA和研发相关网站),所以需要一个获取域名对应IP的工具

1. 安装

# CentOS 7
sudo yum install bind-utils
# Ubuntu 18.04
sudo apt-get install dnsutils
# MacOS
brew install bind

2. 使用

nslookup可以根据域名获取对应的IP,分为交互式和非交互式两种使用方式

  1. 非交互式

nslookup url即可

pptg:~/ $ nslookup www.baidu.com                                      [9:16:10]
Server:		114.114.114.114
Address:	114.114.114.114#53

Non-authoritative answer:
www.baidu.com	canonical name = www.a.shifen.com.
Name:	www.a.shifen.com
Address: 180.101.50.188
Name:	www.a.shifen.com
Address: 180.101.50.242
 









  1. 交互式

nslookup进入交互页面

pptg:~/ $ nslookup                                                    [9:16:15]
> www.baidu.com
Server:		114.114.114.114
Address:	114.114.114.114#53

Non-authoritative answer:
www.baidu.com	canonical name = www.a.shifen.com.
Name:	www.a.shifen.com
Address: 180.101.50.188
Name:	www.a.shifen.com
Address: 180.101.50.242
> www.google.com
Server:		114.114.114.114
Address:	114.114.114.114#53

Non-authoritative answer:
Name:	www.google.com
Address: 31.13.88.169