Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我一直在搞乱getaddrinfo和getnameinfo,但最接近有用输出的是“localhost.localdomain”。我不确定要为 getaddrinfo 的“节点”或“服务”参数传递什么,尽管我认为这是我想要的功能。
实际上,Zxaos 的答案几乎就是我一直在寻找的答案(即使它适用于 C 而我的适用于 C++,但两者都适用):
如何在 C 中找到当前机器的完整主机名(主机名和域信息)?
所以我想我的问题是重复的......
您可以尝试以下命令:
#hostname --fqdn
适用于 OpenSuse 风格。不确定 Ubuntu。