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.
我正在使用套接字进行连接,客户端需要服务器的主机名。我在同一台机器上运行它并且我的主机名有效。问题是我的主机名真的很长,我不想把所有的时间都花在打字上。所以,我所做的是我 sudo su'd and did
hostname brandon
然后我输入
hostname
它显示“布兰登”
然后我以brandon作为主机名运行程序,它说它无法解析主机。有什么帮助吗?我什至在 /etc/hostname 中编辑了我的主机名文件
它/etc/hosts不是/etc/hostname
/etc/hosts
/etc/hostname
您可以在 /etc/hosts 文件中添加一行来解析主机名查找
xxx.xxx.xx.xxx brandon
替换xxx.xxx.xx.xxx为真实IP地址
xxx.xxx.xx.xxx