curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: How do I use curl to find out the public IP address of my Linux server within my internal LAN network?

From: Timothe Litt <litt_at_acm.org>
Date: Sun, 2 Jan 2022 08:19:44 -0500

It depends on why you want to know.

There are many websites that will return the public address from which a
query is received.  You need to decide whether or not you trust them -
most are OK.  Many try to return additional information from your web
browser - and rely on javascript to do so.  cURL won't work with those.

Some only respond to IPv4 - if you need to know about IPv6, your choices
are more limited.  But IPv6 is rarely NATed (though it may be tunneled).

A web search for "my ip address" will turn up a number of sites.

Among many others, https://www.myip.com https://www.ipify.org/
https://seeip.org/ https://getjsonip.com/ have a JSON API, which may be
helpful.  A web search for "my ip address JSON" will give a current list
- many of which provide a cURL command.

In addition, if the goal is to make your site reachable, look for
dynamic DNS services (e.g. no-ip.com, dynu.com), which will register
your current IP address in the DNS.  You can lookup that name to get
your current address.  This is also one of many - some are free (usually
with restricted domain names), others may charge.  Many routers support
one or more of these services.  In these cases, you can determine your
IPaddress with dig, host, nslookup - or cURL --verbose.  A web search
for "dynamic ip update client" may be helpful.


Timothe Litt
ACM Distinguished Engineer
--------------------------
This communication may not represent the ACM or my employer's views,
if any, on the matters discussed.

On 02-Jan-22 00:31, Turritopsis Dohrnii Teo En Ming via curl-users wrote:
> Subject: How do I use curl to find out the public IP address of my
> Linux server within my internal LAN network?
>
> Good day from Singapore,
>
> How do I use curl to find out the public IP address of my Linux server
> within my internal LAN network?
>
> Thank you.
>
> Regards,
>
> Mr. Turritopsis Dohrnii Teo En Ming
> Targeted Individual in Singapore
> 2nd Jan 2022 Sunday Singapore Time

-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-users
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2022-01-02