Linux CLI Get My Public IP

Posted: | Last updated: | less than 1 minute read

In this article, we are going to learn how to find Public IP Address of our computer using Linux curl command.

Usually, if we want to find the public IP Address, we go to google and search what is my ip address. But if you are using Linux, then you can get your public IP Address from the command line using curl command.

The curl command with ifconfig.me argument will show your public IP Address.

$ curl ifconfig.me

Output:

vagrant@ubuntu-bionic:~$ curl ifconfig.me
124.123.106.196

For additional information use curl ifconfig.me/all

$ curl ifconfig.me/all

The output will show the public IP Address, user agent and the port you are connected.

ip_addr: 124.123.106.196
remote_host: unavailable
user_agent: curl/7.58.0
port: 18982
language:
referer:
connection:
keep_alive:
method: GET
encoding:
mime: */*
charset:
via: 1.1 google
forwarded: 124.123.106.199, 216.239.34.21

Tags:

Categories:

Updated: