top of page


How to Check Global IP Address with Commands

Updated: Dec 12, 2022


I recently realized that how to check global IP addresses is slightly different depending on the person. So I’d like to talk about “How to check global IP address with commands (crul/dig/nslookup)”

Although, some people might wonder “Is it possible to check IP addresses with command?” “There are ways other than using curl?”.

So, I’m going to explain the way of finding your IP with web brewers as well.

Execution Environment

  • Linux environment

OS: Ubuntu 20.04.5 LTS (WSL2)

・Shell: bash

・Locale: Japan

  • Windows environment

・OS: Windows11(Version:21H2)

・Shell: Command prompt

・Language: Japanese

How to check with browser

This is the most common way of checking IP addresses.

Whether you are an IT infrastructure engineer or not, when you check your PC’s global IP address, I think using IP verification sites with a browser is the most common way.


The principle is very simple.

When a client (user) uses a browser to access a web server, it sends an HTTP request to the server using HTTP(S) protocol.

In this case, the “HTTP request” that a browser sends is generally divided into four structures.

・Specify communication protocols and method “Request Line”

・Contains information of the sender of the request “Header Line”

・Empty Line

・”Message Body”

This “header line” has a “request header” which has information about the IP address of the client (user) who just sent the access request.

In IP verification sites, it uses the request header information to find the IP address of a client who accesses the site.

This principle is also being used for the commands described below.


A method with curl command (Linux&Windows)


When it comes to using a command to check IP addresses, the curl command is the most standard method.

This command itself is a wonderful command which is able to send and receive data over a variety of communication protocols. Generally, it is being used to check if the web server is working properly.

In recent Linux’s major distributions and Windows 10(from 2018 Ver.1803 (RS3)), curl has been installed as standard.

  "origin": ""
 ※output as json format

The main usage is described above.

Some people might wonder “did it send a request to a website?”, but it is just like I described above, the principle is the same as using the “request header “ method.

The difference is domain name

With the curl command, you send an HTTP request to the IP verification website, and then get only the IP address from a request header information, and then get the IP address as a response.

There are several websites for IP address verification, and I think the choice is your preference of the domain name.

In conclusion, please be aware that “the curl command is not a command that checks global IP internally”. It’s just using an external service.


How to check with dig・nslookup command(Linux・Windows)

・dig (Linux)

・nslookup (Windows)

Familiar commands for domain verification.

Although the two above commands have different names and tools, they are used in about the same way in this case, so I’m going to explain them at once.

This command is a tool that enquires about DNS servers and gets DNS record responses, but there are DNS servers that can tell your global IP address.




For example, in particular DNS servers listed above, the specific query will return the global IP of the client who sent a request.

This feature is primarily used to check whether or not using the DNS service, but it seems not many people know that.

I checked their official documents of these companies, and articles written by their employees. There are actually few descriptions about this system and its usage.

I’m going to use the DNS server of “Cisco(OpenDNS)”, the one that seems existence is published.

dig @ +short

If you use “dig”, it can display only global IP using the “+short” option.


With “nslookup” there is no shortening option, but it is still shorter than the full display of “dig” which is easier to read.

Aside: Google’s DNS

Google actually has a few descriptions in their public documents as well.

However, there is no perfect description of the result I can get about the command, and unlike Cisco, it responds with a TXT record that the command becomes a little longer. So, I’m skipping an explanation for this one.


curl or dig or nslookup, which command is more convenient?

All of the commands give you the same result which is “global IP of client executed the command”.

Therefore, you can use whichever command you prefer

I bet this answer doesn’t satisfy you.

There is not much difference, but if I must say, dig & nslookup is more stable.

The method with curl, the web server that you are querying must be running, otherwise you can’t get the result.

When I wrote this article, I accessed a few IP verification service sites, but there were some websites that returned “429 Too Many Requests”.

On the other hand, dig and nslookup are methods to enquire to DNS

Yes, the DNS servers managed by Google and Cisco(OpenDNS) are stable. Or rather, it would be a disaster if they ever stop running.

If I consider the stability of the servers, compared with 1WEB server and a DNS server of large companies, the latter is clearly better.

Aside: Actually, dig & nslookup are faster internally

There is no perceptible difference, but the “internal” execution speed with dig & nslookup is faster.

The difference in speed is due to the fact that curl uses TCP which checks the response from communication protocol, on the other hand, dig & nslookup use UDP which sends data unilaterally.


“There are not many differences that you can use the method you are comfortable with”

“If I must say, dig & nslookup are faster”

There are many occasions to check a server's global IP. I’d be happy if you find this article helpful.

Thank you for reading!

This blog post is translated from a blog post written by Naka Tomo on our Japanese website Beyond Co.

bottom of page