How To Find Your Public IP Address From The Terminal

How To Find Your Public IP Address From The Terminal

Finding the IP address of your local machine couldn’t be easier – ipconfig on Windows or ifconfig on Linux will bring up all of your local network interfaces and list the IP addresses associated with them. Finding out your public IP address, which is the IP addresses associated with your internet connection can be a little more tricky.

Whatsmyip will show your your public IP address on their webpage when you visit them. Perhaps more interestingly, when visited with Linux curl or wget only the IP public address is displayed without any HTML or other content around it.

You can therefore use curl to read your public IP address into a variable, and then use it in as you need to.

james.coyle

John Ball

15-Nov-2015 at 10:39 am

I think you misunderstood Jason’s point. You stated that ipconfig on Windows or Linux will bring up all of your local network interfaces and list the IP addresses associated with them. That’s true for Windows but in Linux the closest equivalent command is ifconfig.