- Algorithm for Determining ISP-Assigned Network Interface Address
- Posted by Cool Guy on December 7th, 2004
Could anyone propose an algorithm for determining a box's public,
ISP-assigned network interface address, from a list of all the box's
network interface addresses?
I'm writing a server which allows the user to select the network interface
on which to listen, and would like to set the default to the public one.
- Posted by Dave Vandervies on December 7th, 2004
In article <chq1cnshtc0$.dlg@cool.guy.abc.xyz>,
Cool Guy <coolguy@abc.xyz> wrote:
First step is to decide what happens if there isn't exactly one
ISP-assigned external IP address.
(What happens on my home workstation behind a NAT gateway, with only a
non-routable local address? How 'bout a laptop with multiple possible
connection methods where more than one, or none at all, can be active
at any given time?)
There's not really any easy way to do things that doesn't obviously fail
for some of the interesting cases.
Probably the best way to go is to pick the one that the default route
uses. In the absence of a default route, you could try to filter out
non-routable (localhost, RFC1918, RFC3330) addresses and pick a routable
one if there is one.
localhost is probably the only sensible way to handle not having any
"real" network interfaces.
Given all that, I'm not sure if there's a sensible way to turn a set
of heuristics like this into an algorithm. Though if you really want
an algorithm:
--------
For each interface
Assign a value representing the interface's probability of being an
external-facing one with an ISP-assigned address, based on factors
such as:
-existence of a default route through that interface
-existence of non-default routes through that interface
-whether the IP address is a RFC1918 non-routable address
-whether the IP address is reserved
-whether the address is a loopback address
If interface is the highest-probability one examined so far, store it
as the best candidate (replacing the previous best candidate if
one exists)
Return stored best candidate
--------
dave
--
Dave Vandervies dj3vande@csclub.uwaterloo.ca
--Ron Natalie and Kevin Goodsell in comp.lang.c++
- Posted by Willem on December 7th, 2004
Cool wrote:
) Could anyone propose an algorithm for determining a box's public,
) ISP-assigned network interface address, from a list of all the box's
) network interface addresses?
)
) I'm writing a server which allows the user to select the network interface
) on which to listen, and would like to set the default to the public one.
As far as I know, non-public IP addresses are supposed to be from
a specific range, such as 10.x.x.x or 192.168.x.x or something.
There's probably an RFC describing this. (You should also look for the
IPv6 version of that, I guess...)
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
- Posted by Bill Godfrey on December 10th, 2004
Cool Guy <coolguy@abc.xyz> wrote:
The IP address as seen from the other side of a NAT box? You'd have to ask
a server on the other side to report what it thinks your IP address is.
Bill, sorry there's no simple way.