ICMP协议ping

  1. ping -S 本机IP -c 3 www.google.com

查看IP地址

查看内网的 IP 地址

  1. [~]$ ipconfig getifaddr en0
  2. 192.168.30.25

或者

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

查看公网 IP 地址

  1. [~]$ curl myip.ipip.net
  2. 当前 IP123.45.78.80 来自于:中国 福建 三明 移动

或者

  1. [~]$ curl ifconfig.me
  2. 123.45.78.80%

或者:

  1. [~]$ curl ipinfo.io/json
  2. {
  3. "ip": "123.45.78.80",
  4. "city": "Xiamen",
  5. "region": "Fujian",
  6. "country": "CN",
  7. "loc": "24.4798,118.0819",
  8. "org": "AS9808 China Mobile Communications Group Co., Ltd.",
  9. "timezone": "Asia/Shanghai",
  10. "readme": "https://ipinfo.io/missingauth"
  11. }%

查看域名的IP地址

  1. ~% nslookup www.baidu.com
  2. Server: 52.80.66.30
  3. Address: 52.80.66.30#53
  4. Non-authoritative answer:
  5. www.baidu.com canonical name = www.a.shifen.com.
  6. Name: www.a.shifen.com
  7. Address: 220.181.38.150
  8. Name: www.a.shifen.com
  9. Address: 220.181.38.149