Several ways to query the IP of the extranet under Linux.

Source: Internet
Author: User
Tags bash script example

Several ways to query the IP of the extranet under Linux. Curl Plain Text Format output:
curl icanhazip.comcurl ifconfig.mecurl curlmyip.comcurl ip.appspot.comcurl ipinfo.io/ipcurl ipecho.net/plaincurl www.trackip.net/i

Curl JSON format output:
curl ipinfo.io/jsoncurl ifconfig.me/all.jsoncurl www.trackip.net/ip?json (有点丑陋)

Curl XML Format output:
curl ifconfig.me/all.xml

Curl gets all IP details (excavator)
curl ifconfig.me/all

Use Dydns (useful when you use the Dydns service)
curl -s ‘http://checkip.dyndns.org‘ | sed ‘s/.*Current IP Address: \([0-9\.]*\).*/\1/g‘curl -s http://checkip.dyndns.org/ | grep -o "[[:digit:].]\+"

Use Wget instead of Curl
wget http://ipecho.net/plain -O - -q ; echowget http://observebox.com/ip -O - -q ; echo

Using the host and Dig commands

If so, you can also use the host and dig commands directly.

host -t a dartsclink.com | sed ‘s/.*has address //‘dig +short myip.opendns.com @resolver1.opendns.com

Bash Script Example:
#!/bin/bashPUBLIC_IP=`wget http://ipecho.net/plain -O - -q ; echo`echo $PUBLIC_IP

Several ways to query the IP of the extranet under Linux.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.