Main
2022-04-02

Shorter Hacks 14: Get external IP

You are behind a NAT and need your "outer" IP address? You can use curl with one of several handy websites: For example: curl icanhazip.com or curl ifconfig.me. If you want to self-host such a service with nginx it's as simple as:

location / {
    default_type text/plain;
    return 200 "$remote_addr\n";
}

en shorterhacks nginx nat

The series Shorter Hacks consists of tips and tricks for Linux nerds. Flags, hacks, and features of everyday tools that you might not know already, but that will enrich your life. I currently have a list of around 40 hacks I collected and plan to publish them roughly weekly. In order for this series to continue, please send me your best trick(s). The focus is not on fancy new tools or extensive rc-file content, but little known features in software most people already use. Send them to michael bei schoenitzer punkt de.
This blog has an Atom-Feed and I plan to also post the Shorter Hacks articles on Mastodon and Twitter.

Creative Commons License "Shorter Hacks 14 Get external IP" by Michael F. Schönitzer is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.