DEV Community

Discussion on: Get your public IP address from command line

Collapse
peter279k profile image
peter279k • Edited on

We can also use other third-party services to query the public IP on our host:

$ curl ifconfig.me
$ curl icanhazip.com
$ curl icanhazip.com
$ curl ipecho.net/plain
Enter fullscreen mode Exit fullscreen mode

And we can use the host command to resolve OpenDNS service on our host to get the current public IP address:

host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'
Enter fullscreen mode Exit fullscreen mode