日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux查看公网IP和私网(内网)IP的方法

發布時間:2023/12/20 linux 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux查看公网IP和私网(内网)IP的方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

查看Linux公網IP地址

查看Linux公網IP很簡單,結合第三方網站輔助一下即可,直接curl一下ip.sb或者cip.cc即可

curl ip.sb # 只顯示ipv4curl cip.cc #顯示ipv4和地址信息

查看Linux的內網IP地址

ifconfig -a


直接執行上述命令即可查看到內網IP

拓展:查詢公網ip

? ? ? ? cip.cc

????????

命令行查詢(詳細):# UNIX/Linux: curl cip.cc# Windows: telnet cip.cc ftp cip.cc命令行查詢(純ip):#UNIX/Linux: curl ip.cip.cc# Windows: telnet ip.cip.cc ftp ip.cip.cc

? ? ? ? ip.sb

  • Example (Plain text):?https://api.ip.sb/ip?(Listen on both IPv4 and IPv6) or?curl ip.sb
  • Example (Plain text):?https://api-ipv4.ip.sb/ip?(Listen on IPv4 only) or?curl -4 ip.sb?or?curl ipv4.ip.sb
  • Example (Plain text):?https://api-ipv6.ip.sb/ip?(Listen on IPv6 only) or?curl -6 ip.sb?or?curl ipv6.ip.sb

Usage example (Shell script):

#!/bin/ship=$(curl -s https://api.ip.sb/ip) echo "My IP address is: $ip"

Output example:

IPv4 address:

192.0.2.2

IPv6 address:

2001:db8::2

GeoIP (Get IP address location in JSON format):

Calling the API endpoint without any parameter will return location information for the visitor IP address:

  • Example (JSON):?https://api.ip.sb/geoip
  • Example (JSONP):?https://api.ip.sb/geoip?callback=getgeoip

Appending an IP address as parameter will return location information for this IP address:

  • Example (JSON):?https://api.ip.sb/geoip/185.222.222.222
  • Example (JSONP):?https://api.ip.sb/geoip/185.222.222.222?callback=getgeoip
  • Example (JSON):?https://api.ip.sb/geoip/2a09::
  • Example (JSONP):?https://api.ip.sb/geoip/2a09::?callback=getgeoip

Usage example:

<script type="application/javascript"> function getgeoip(json){document.write("Geolocation information for IP address: ", json.ip);document.write("Country: ", json.country);document.write("Latitude: ", json.latitude);document.write("Longitude: ", json.longitude); } </script><script type="application/javascript" src="https://api.ip.sb/geoip?callback=getgeoip"></script>

Usage example (jQuery):

<script type="application/javascript"> $(document).ready(function() {$.getJSON("https://api.ip.sb/geoip?callback=?",function(json) {document.write("Geolocation information for IP address: ", json.ip);document.write("Country: ", json.country);document.write("Latitude: ", json.latitude);document.write("Longitude: ", json.longitude);}); }); </script>

JSON Output Schema

The output is a JSON object containing the following elements:

Please note that the IP location database may not contain all information about a given IP. In this case, only the available data is displayed.

  • ip?(Visitor IP address, or IP address specified as parameter)
  • country_code?(Two-letter ISO 3166-1 alpha-2 country code)
  • country?(Name of the country)
  • region_code?(Two-letter ISO-3166-2 state / region code for US and Canada, FIPS 10-4 region codes otherwise)
  • region?(Name of the region)
  • city?(Name of the city)
  • postal_code?(Postal code / Zip code)
  • continent_code?(Two-letter continent code)
  • latitude?(Latitude)
  • longitude?(Longitude)
  • organization?(ASN + ISP name)
  • timezone?(Time Zone)

Output example:

The following example use?xTom?server IP: city, region, and postal code information is not available and thus not present in the output JSON object:

{"ip": "185.255.55.55","country_code": "NL","country": "Netherlands","continent_code": "EU","latitude": 52.3824,"longitude": 4.8995,"asn": "3214","organization": "xTom Limited","timezone": "Europe/Amsterdam", }

參考:

????????IP查詢 - 查IP(www.cip.cc)查IP(www.cip.cc)網站, 提供免費的IP查詢服務,命令行查詢IP, 并且支持'PC網站, 手機網站, 命令行(Windows/UNIX/Linux)' 三大平臺, 是個多平臺的IP查詢網站, 更新即使, 數據準確是我們的目標https://www.cip.cc/
https://ip.sb/api/https://ip.sb/api/

總結

以上是生活随笔為你收集整理的Linux查看公网IP和私网(内网)IP的方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。