温馨提示×

ubuntu域名怎么查

小樊
34
2026-09-01 08:33:16
栏目: 云计算

在 Ubuntu 里“查域名”一般分几种情况,下面给你最常见的几种方法和命令:


一、查本机域名(主机名)

hostname

或查看完整信息:

hostnamectl

查看 /etc/hostname 文件:

cat /etc/hostname

二、查 DNS 配置(系统用哪个域名服务器)

cat /etc/resolv.conf

常见内容:

nameserver 8.8.8.8

如果是用 systemd-resolved

systemd-resolve --status

(新版本可能是 resolvectl status


三、查某个域名的解析结果(最常用)

1️⃣ nslookup

nslookup example.com

2️⃣ dig(推荐)

dig example.com

只查 IP:

dig +short example.com

3️⃣ host

host example.com

四、查本机绑定了哪些域名(服务器配置)

如果是 Web 服务器:

Nginx

grep server_name /etc/nginx/sites-enabled/* -R

Apache

grep ServerName /etc/apache2/sites-enabled/* -R

五、查本机 hosts 文件里的域名

cat /etc/hosts

六、查公网 IP 对应的域名(反向解析)

dig -x 你的IP

如果你说的是**“Ubuntu 服务器绑定的域名怎么看”“域名指向哪台 Ubuntu”**,可以告诉我具体场景,我给你更精确的命令。

0