Tuesday, April 28, 2020

how to find my public ip address in linux ?

Using dig


dig (domain information groper) is a simple command line utility for probing DNS name servers. To find your public IP addresses, use the opendns.com resolver as in the command below:


Syntax:


dig +short myip.opendns.com @resolver1.opendns.com


Example:


dig +short myip.opendns.com @resolver1.opendns.com


111.125.200.200


Using host


host command is an easy-to-use command line utility for carrying out DNS lookups. The command below will help to display your system public IP address.


Syntax:
host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'


Example:


host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'
111.125.200.200


Using wget


curl is a popular command line tool for uploading or downloading files from a server using any of the supported protocols (HTTP, HTTPS, FILE, FTP, FTPS and others). The following
commands display your public IP address.


Syntax:


wget -qO- http://ipecho.net/plain | xargs echo


Or


wget -qO - icanhazip.com


Example:


 wget -qO- http://ipecho.net/plain | xargs echo
111.125.200.200


 wget -qO- http://ipecho.net/plain | xargs echo
111.125.200.200


Using curl


curl is a popular command line tool for uploading or downloading files from a server using any of the supported protocols (HTTP, HTTPS, FILE, FTP, FTPS and others). The following
commands display your public IP address.


Syntax:


curl ifconfig.me


Example:
curl ifconfig.me
111.125.200.200


The following commands will get you the IP address list to find public IP addresses for your machine:

  • curl ifconfig.me
  • curl icanhazip.com
  • curl ipinfo.io/ip
  • curl api.ipify.org
  • curl checkip.dyndns.org
  • curl ident.me
  • curl bot.whatismyipaddress.com
  • curl ipecho.net/plain

No comments:

Post a Comment