looking up ip global IP address from inside LAN

Peter Crowther peter at crowther.demon.co.uk
Tue Jul 29 18:55:44 UTC 2003


> From: [...] Stoffel, Andrew
> In theory you should be able to get the address from traceroute
> because it SHOULD be the next address following your router's LAN
> address when you use traceroute...

Ah, this takes me back to my days of teaching networking for a living ;-).

Unfortunately not, as the packets come back from the interface of each
router that's on 'your' side.  So you'd get the LAN address of the NAT
gateway/router as hop 1, followed by your side of the first of the ISP's
routers as hop 2.

There is no way [that I can see] of obtaining the address through IP or
ICMP; you get the wrong side of the interface.  You can't use loose or
strict source routing because you'd need to know your external IP to direct
the datagrams back to you (and anyway they're dropped by most modern routers
as a hackers' tool).  So that's OSI layers 1-3 out (1 and 2 aren't relevant
to this discussion as they're LAN-side only, anyway).  Layers 4, 5 and 6 are
unlikely to help much unless there's something you could do with one of the
QoS protocols - I don't know 'em that well.  That leaves the good old
Application layer.  Hmmm...

Application 1: SNMP.  If your router can be SNMP-managed and implements
Internet MIB I or II, you can ask it for all its IP addresses.  Take away
the local one from the list, and you have its external address.  Or
addresses, if it has more than one; it would then be up to you to work out
what it had.  This would be LAN-only.  Few low-end routers support SNMP,
however.

Application 2: HTTP and a friendly Web site.  As already described, there
are Web sites out there that will hand back your outside IP address in an
easy-to-decode form; the Web server has it readily to hand.  This is not
LAN-only.

Application 3: A custom protocol with a small server that looked at TCP or
UDP endpoints and returned the apparent IP address.  Yet another protocol;
there are more (and better-maintained) Web servers that offer an equivalent
service; and it's still not LAN-only.

Application 4: HTTP or telnet and an unfriendly Web site.  If you don't mind
making it utterly router-specific, as another poster pointed out, it should
be possible to screen-scrape the responses from your router when you log on
to it.  This is LAN-only, but icky.

Justin, why the requirement for LAN-only?  This is trivial without that
requirement, complex and router-dependent with it.

		- Peter



More information about the Squeak-dev mailing list