ICMP协议ping
ping -S 本机IP -c 3 www.google.com
查看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 myip.ipip.net
当前 IP:123.45.78.80 来自于:中国 福建 三明 移动
或者
[~]$ 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"
}%
查看域名的IP地址
~% nslookup www.baidu.com
Server: 52.80.66.30
Address: 52.80.66.30#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 220.181.38.150
Name: www.a.shifen.com
Address: 220.181.38.149