Re: Get the external IP address from a Linux box
On Sun, 2018-05-27 at 21:10 +1000, Andrew McGlashan wrote:
> On 26/05/18 20:53, André Rodier wrote:
> > The code is on github, as part of my small homebox project. I am not
> > sure it deserves a dedicated repository ;-).
> > https://github.com/progmaticltd/homebox/blob/dev-arodier/install/playbo
> > oks/roles/system-prepare/files/external-ip
> My take from your script is at:
> http://ix.io/1bwE/ [lose the trailing / for the raw file]
> NB: I am deliberately using bash instead of dash for a number of reasons....
I use dash because it is the default shell for the root account on a
number of distributions, and has a better security history than bash.
> > It is very simple, but it does what I wanted:
> > - Query multiple servers.
> My script also does the Google DNS lookup.
I have four IP addresses, and Goodle DNS returns the first one,
although I query from the second one.
> > - Count the IP addresses returned, and order them by the most probable
> > result.
> > - Return the external IP address only if above a certain level of
> > confidence (actually 100%).
> > - The list of IP addresses is in a separate configuration file.
> I've kept the option to use external config file; otherwise it
> uses what is known already n the script.
> I've used the following for quite some time, but it usually takes too
> long (for my liking) to get an answer and it doesn't use https either:
> curl -s ifconfig.me
Yes, I can see it's very slow.