What does HackerNews think of myip?
Get your external IP address using multiple STUN servers
Here is an implementation which uses parallel STUN queries to report address reliably as fast as possible: https://github.com/Snawoot/myip
or
dig @ns1.google.com o-o.myaddr.l.google.com TXT +short | tr -d \"
or
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:
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.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