在 CentOS 中“查看域名”通常有几种不同场景,下面按常见需求说明:
hostname
或查看完整 FQDN:
hostname -f
也可以查看:
cat /etc/hostname
cat /etc/hosts
里面可能写了类似:
127.0.0.1 localhost
192.168.1.10 server.example.com
cat /etc/resolv.conf
示例:
nameserver 8.8.8.8
search example.com
nslookup example.com
或
dig example.com
(dig 可能需安装:yum install bind-utils)
cat /etc/resolv.conf | grep search
nmcli dev show | grep DNS
如果你说的“查看域名”是指:
dig -x IP可以告诉我你具体想查哪一种,我可以给更精确的命令。