Re: Get the external IP address from a Linux box
- Date: Sat, 26 May 2018 11:53:34 +0100
- From: André Rodier <andre@xxxxxxxxx>
- Subject: Re: Get the external IP address from a Linux box
On Thu, 2018-05-24 at 07:22 +0100, André Rodier wrote:
> I am looking for a native package on Debian, that can give me the
> external IP address of the machine.
> So far, I used internet sites, but I am sure there is a package that
> that properly, especially if one site is unreachable.
> Something I can run from the command line, and that would return the
> external IP address.
After a few tests, I wrote a script that perhaps some people can use.
First, interestingly, the google DNS trick did return the first IP
address assigned to me, where I had four, whatever the server I used.
The code is on github, as part of my small homebox project. I am not
sure it deserves a dedicated repository ;-).
It is very simple, but it does what I wanted:
- Query multiple servers.
- Count the IP addresses returned, and order them by the most probable
- 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.
- It is quickly made
- I am not a bash expert
- Yes, it would be nicer in Python