Pages

Wednesday, May 07, 2025

How to check your public IP address from FreeBSD or Linux console

Web service available at https://ifconfig.me/ will expose the client IP address. This is useful when you do not know your public IP address as you are behind the NAT (Network Address Translation) in some public Wi-Fi access point or even in your home behing CGNAT (Carrier-Grade NAT) very often used by Internet Service Providers using IPv4.

How we can leverage it from FreeBSD? 

It is easy. Just use old good fetch command available on FreeBSD by default to retrieve a file by Uniform Resource Locator (URL).

Oneliner:

fetch -qo - https://ifconfig.me | grep "ip_addr:"


How we can leverage it from Linux? 

It is easy. I use Debian and there is old good wget command available by default. It can be used to retrieve a file by Uniform Resource Locator (URL) similarly to fetch on FreeBSD.

Oneliner:

wget -o /dev/null -O - https://ifconfig.me | grep "ip_addr:"

 


Conclusion

In Unix-like operating systems is very easy to leverage standard tools to get job done.

No comments:

Post a Comment