Get the external IP address from a Linux box
Le 05/24/18 à 22:17, Stefan Monnier a écrit :
> Alberto Luaces <firstname.lastname@example.org> writes:
>> Joe writes:
>>> On the assumption that you are using a router of some kind, your public
>>> IP address will be that of the router WAN port (cable, ADSL, etc.) and
>>> there will be a method of determining that by connecting to the router
>>> as an administrator. That method will depend entirely on the router.
>> If the router supports upnp and it is activated, you can check the
>> external IP in an device-independent way with
>> upnpc -l | grep ExternalIPAddress
> The miniupnpc Debian package even comes with the `external-ip` script
> which basically does the above.
> I just tried it and it worked (tho only after I installed & enabled
> miniupnpd on my OpenWRT router). Of course, the IP address that my
> router gets could itself be an "internal IP" behind a NAT firewall of my
> ISP, so even if `external-ip` does give an answer I'm not sure it's
> guaranteed to be "the" external IP address.
You could also be natted to one pool, so get different addresses for
different connections, or even have different services natted to
different pools (eg because there is a transparent proxy for outgoing