Efficient public IP retrieval

eed6134 Bump dependencies, break down deps vs project build for caching

~nickbp pushed to ~nickbp/iplookup git

1 year, 23 days ago

27d89b6 Add build status badge

~nickbp pushed to ~nickbp/iplookup git

1 year, 1 month ago


builds.sr.ht status

Prints your public IP address to stdout by querying a specified STUN server.

Useful for finding your public IP when behind a NAT or firewall. Uses an open standard that's faster and arguably safer than querying some rando's "what is my ip" website.


Compile the crate:

$ cargo install iplookup
$ iplookup stun.l.google.com:19302

Or use the prebuilt amd64/arm64 docker image:

$ docker run nickbp/iplookup:TAG /iplookup stun.l.google.com:19302


$ git clone https://git.sr.ht/~nickbp/iplookup
$ cd iplookup
$ cargo build --release
$ ./target/release/iplookup stun.l.google.com:19302

Note: Building iplookup requires Rust 1.39.0 or later.


  • To simplify scripting, the only thing written to stdout is the resulting public IP. Anything else goes to stderr.
  • Automatic retries with exponential backoff, waiting a maximum of 31s for a response.
  • Prints additional information about the request and response if the DEBUG environment variable is non-empty.


This project is licensed under GPL 3 or any later version.