macOS查看IP地址的命令

查看内网的 IP 地址:

[~]$ ipconfig getifaddr en0
192.168.30.25
# 或者
[~]$ ifconfig en0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether d4:61:9d:11:c2:94 
	inet6 fe80::cbc:309b:57a4:5cf6%en0 prefixlen 64 secured scopeid 0x5 
	inet 192.168.30.25 netmask 0xffffff00 broadcast 192.168.31.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active

查看公网 IP 地址:

[~]$ curl ifconfig.me
123.45.78.80%

[~]$ curl ipinfo.io/json
{ 
  "ip": "123.45.78.80",
  "city": "Xiamen",
  "region": "Fujian",
  "country": "CN",
  "loc": "24.4798,118.0819",
  "org": "AS9808 China Mobile Communications Group Co., Ltd.",
  "timezone": "Asia/Shanghai",
  "readme": "https://ipinfo.io/missingauth"
}%   

[~]$ curl icanhazip.com
123.45.78.80

[~]$ curl ident.me
123.45.78.80%                                                                                                                                                                                               

[~]$ curl whatismyip.akamai.com
123.45.78.80%

[~]$ curl tnx.nl/ip
123.45.78.80%

[~]$ curl myip.dnsomatic.com
123.45.78.80% 

[~]$ curl myip.ipip.net
当前 IP:123.45.78.80  来自于:中国 福建 三明  移动

[~]$ curl http://members.3322.org/dyndns/getip
123.45.78.80
    原文作者:liaowenxiong
    原文地址: https://blog.csdn.net/liaowenxiong/article/details/121987786
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞