linux下如何获取服务器的ip地址?
linux下如何获取服务器的IP地址?
我需要在 Linux 中使用 bash 命令来告诉我 IP 地址。
How can I get the ip address of a server in linux?
I need to use the bash command in Linux to tell me the IP address.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尝试从 BASH 获取此信息,您可能需要使用 nslookup。例如:
我应该补充一点,IP 地址不代表一台计算机,而是代表一个网络接口。一台计算机可以有任意数量的网络接口(和 IP 地址)。此外,网站或域可能有许多机器(因此有更多的网络接口和 IP 地址)。当使用 nslookup 进行查询时,您将获得给定域名的至少一个 IP 地址(假设 DNS 正在工作并且不会由于某种原因而失败),但它不一定会为您提供所有地址。
If you are trying to get this information from BASH, you probably want to use nslookup. For example:
I should add that an IP address does NOT represent a computer, but rather a network interface. And a computer can have any number of network interfaces (and IP addresses). Also, a website or domain may have many machines (and consequently many more network interaces and IP addresses). When querying with nslookup you will get at least one IP address for the given domain name (assuming DNS is working and it doesn't fail for one reason or another), but it won't necessarily give you all the addresses.
如果您只是查看脚本的 IP,则以下内容会更清晰:
例如:
If you are just after the IP for a script, the following is a lot cleaner:
For example: