暗无天日

=============>DarkSun的个人博客

获取系统物理地址的方法

How to Get Your System’s Geographic Location From a Bash Script 看到的。

其实很简单,就是借助两个网络服务来完成

  1. 获取公网IP

    curl https://ipinfo.io/ip
    
    14.120.26.99
    
  2. 根据公网IP获取物理地址

    curl https://ipvigilante.com/$ip
    
    {"status":"success","data":{"ipv4":"14.120.26.99","continent_name":"Asia","country_name":"China","subdivision_1_name":"Guangdong","subdivision_2_name":null,"city_name":"Guangzhou","latitude":"23.11670","longitude":"113.25000"}}