请教个 hostname 的问题
Tofloor
poster avatar
la******ng@outlook.com
deepin
2018-05-24 20:02
Author
我在 1F 的 HTPC 可以使用 hostname 的方式 ping 到 4F 的 PC,但 4F 的 PC 却不能使用 hostname ping 到 1F 的 HTPC,两台同样没有设定 /etc/hosts,请问為什么会有这种差别呢?

Reply Favorite View the author
All Replies
avatar
deepinuser17
deepin
2018-05-24 21:46
#1
在1F的时候,你的机器可以解析4F的机器的IP地址;但4F的机器不能解析1F的机器。

在4F的机器上,运行下面的指令:

$ nslookup <1F机器名>

或:

$ dig <1F机器名+域名> +short

看看是否命令返回有效地址。

例如:

$ nslookup www.utah.edu
Server:                192.168.181.1
Address:        192.168.181.1#53

Non-authoritative answer:
Name:        www.utah.edu
Address: 155.97.137.55

$ $ dig www.utah.edu +short
155.97.137.55
Reply View the author
avatar
la******ng@outlook.com
deepin
2018-05-24 22:21
#2
本帖最后由 s9209122222 于 2018-5-24 14:22 编辑
https://bbs.deepin.org/post/156932
在1F的时候,你的机器可以解析4F的机器的IP地址;但4F的机器不能解析1F的机器。

在4F的机器上,运行下面的 ...
  1. [user@1F ~]$ nslookup 4F
  2. ;; Got recursion not available from 192.168.1.1, trying next server
  3. Server:        2001:b000:168::1
  4. Address:    2001:b000:168::1#53

  5. ** server can't find 4F: NXDOMAIN

  6. [user@4F ~]$ nslookup 1F
  7. ;; Got recursion not available from 192.168.1.1, trying next server
  8. Server:        2001:b000:168::1
  9. Address:    2001:b000:168::1#53

  10. ** server can't find 1F: NXDOMAIN
Copy the Code



都没有啊

Reply View the author
avatar
duanyao
deepin
2018-05-24 23:22
#3
本帖最后由 duanyao 于 2018-5-24 15:27 编辑

可能是运行了 samba,采用的是 WINS 机制。
https://askubuntu.com/questions/ ... e-instead-of-the-ip
https://www.techrepublic.com/art ... -windows-hostnames/

顺便一提,Linux上正统的局域网域名解析方案是 mDNS ,是苹果最早用的,可惜Windows不支持:
https://wiki.archlinux.org/index.php/Avahi

Reply View the author
avatar
wtz
deepin
2018-05-24 23:45
#4
两台机器的hostname是如何分配的呢?是通过DHCP分配的,还是使用系统默认值(比如 localhost)?
Reply View the author
avatar
la******ng@outlook.com
deepin
2018-05-25 02:17
#5
https://bbs.deepin.org/post/156932
两台机器的hostname是如何分配的呢?是通过DHCP分配的,还是使用系统默认值(比如 localhost)? ...

我的 hostname 是一开始安装系统时要求填入的,可能如同 @duanyao 说的是 SAMBA 的关系吧,因為我 4F 有开 SAMBA 共享,但 1F 没有
Reply View the author
avatar
deepinuser17
deepin
2018-05-26 10:46
#6
机器上hostname没有关系.  关键是域名解析服务器要能够解析两台机器的IP地址。

运行一下命令:

$ cat /etc/resolv.conf

然后,ping 域名解析服务器的地址



Reply View the author