Uncategorized

Know Your IP Using Command Line

If you are not behind a router, you can find it out using ifconfig.

If you are behind a router, then your computer will not know about the public IP address as the router does a network address translation. You could ask some website what your public IP address is using curl or wget and extract the information you need from it:

curl -s https://checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'  

or shorter

curl https://ipinfo.io/ip

Leave a Reply

Your email address will not be published. Required fields are marked *