Several ways to query the IP of the outside network under Linux

Source: Internet
Author: User
Tags bash script example curl

Original address: http://my.oschina.net/epstar/blog/513186

Curl Plain Text Format output:
ifconfig . Mecurl curlmyip.comcurl ip.appspot.comcurl ipinfo.io/ipcurl ipecho.net/Plaincurl Www.trackip.net/I

Curl JSON format output:
Curl ipinfo.io/ifconfig. me/all.jsoncurl www.trackip.net/ip?json (a bit ugly)

Curl XML Format output:
ifconfig. Me/all.xml

Curl gets all IP details (excavator)
1 ifconfig. Me/all

Use Dydns (useful when you use the Dydns service)
' http://checkip.dyndns.org ' sed ' s/.*current IP Address: \ ([0-9\.] *\). */\1/g'-S http://checkip.dyndns.org/| grep-o "[[:d Igit:]. \+"

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.

sed ' S/.*has address// '  + short myip.opendns.com @resolver1. opendns.com

Bash Script Example:
#!/bin/bashpublic_ip= 'wget http://ipecho.net/plain-o-Q; Echo 'echo $ Public_ip

Nmap

Several ways to query the IP of the outside network 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.