Skip to content

Instantly share code, notes, and snippets.

@yorickshan
Last active August 17, 2021 02:45
Show Gist options
  • Save yorickshan/481bb1d031c5d5e79f758f9ea82d562c to your computer and use it in GitHub Desktop.
Save yorickshan/481bb1d031c5d5e79f758f9ea82d562c to your computer and use it in GitHub Desktop.
let clientIp
$.getJSON("https://api.ipify.org/?format=json", function(e) {
clientIp = e.ip;
});
// linux 获取内网地址
ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"
// mac 获取内网地址
ipconfig getifaddr en0
// 获取公网地址
curl api.ipify.org
curl cip.cc
curl ip.sb
curl ifconfig.co
curl ifconfig.co/json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment