Web lists-archives.com

Re: Get the external IP address from a Linux box

Le 28/05/2018 à 13:54, Alan Greenberger a écrit :
On 2018-05-26, Pascal Hambourg <pascal@xxxxxxxxxxxxxxx> wrote:
Le 25/05/2018 à 02:17, Alan Greenberger a écrit :

Assuming you are looking for the public internet address of your router,
you could try:
/usr/sbin/arp -n
and it may show up on a line with the HWadress of your router.

Nope. That would just show the internal address of the router.

You are mostly correct.  However, I have one machine on which the
response to
/usr/sbin/arp -n
shows two lines with the HWaddress of the router, one with the internal
address as you said and the other with the external address.  I have no
idea what made arp see the external address.

Thinking of it, a router following the "weak host" model (like Linux does) can advertise any local address on any interface. It can be tested with arping. However I am failing to imagine any plausible scenario which could lead a host on the internal LAN to have the router's external IP address in its ARP cache. It means that either :
- the host sends an ARP query for the router's external IP address
- the router sends an ARP query to the host from its external IP address