What does HackerNews think of myip?

Get your external IP address using multiple STUN servers

Language: Makefile

Why not use protocols which are specifically designed to report mapped IP address like STUN? It's faster as UDP exchange is shorter than 3-way TCP handshake (or even TCP+TLS handshake).

Here is an implementation which uses parallel STUN queries to report address reliably as fast as possible: https://github.com/Snawoot/myip

I'm a big fan of https://httpbin.org/ip

or

dig @ns1.google.com o-o.myaddr.l.google.com TXT +short | tr -d \"

or

https://github.com/Snawoot/myip

This kind of service is exactly what STUN servers are made for. Designed to be used with webrtc, but it works perfectly alright by itself.

There are a plethora of unauthenticated STUN servers around, and while there's still room for abuse, the protocol is a bit more lightweight than full-blown http requests, and faster, too!

I've dabbled with doing this on my own, but I've found `myip` to do the job nicely and without hassle:

https://github.com/Snawoot/myip

I prefer single packet auth with pyknock [1]. SSH config from client side looks like this:

  Host vm vm-0 vm-0.com
      User user
      HostName vm-0.com
      ProxyCommand sh -c "pyknock-client -s 0.0.0.0 -S \"\$(myip)\" open %h "$(pass my/pyknock/%h)" && sleep 1 && exec nc -4 %h %p"
      Port 1792
Where `myip` [2] is an small utility which reliably detects my external IP address.

[1] https://github.com/Snawoot/pyknock/

[2] https://github.com/Snawoot/myip

I had some auto-tests for VPN app which were relying on similar web-service to check own IP address. One day service become unavailable and autotests got broken. IIRC it was (https://canihazip.com/s)

I decided to solve this task in a fast and reliable fashion, so I made a tool which discovers own IP address using major public STUN servers: https://github.com/Snawoot/myip

Program issues parallel queries to public STUN servers to determine public IP address and returns result as soon as quorum of matching responses reached.

Works fast and reliable, especially compared to services requiring HTTPS:

  user@dt1:~> time curl https://api.ipify.org
  45.152.165.44
  real 0m2,515s
  user 0m0,030s
  sys 0m0,019s
  
  
  user@dt1:~> time curl ifconfig.co/
  45.152.165.44
  
  real 0m0,131s
  user 0m0,011s
  sys 0m0,008s
  
  
  user@dt1:~> time myip
  45.152.165.44
  
  real 0m0,084s
  user 0m0,012s
  sys 0m0,012s