Re: At a loss figuring out if an IP is on LAN or INET
- From: "Simon Verona" <nomail@xxxxxxxxxx>
- Date: Fri, 28 Apr 2006 13:17:52 +0100
The correct way is to AND both the PC's own IP address and the destination
IP address each with the subnet mask... If the result is the same, then
they are on the same subnet of the network.
Out of interest the result of AND'ing the ip address against the subnet mask
produces what is called the "Network Address". For class B addresses (such
as your example) this is simply the same as the first two octects followed
by 2 zeros, but this may not always be the case...
HTH
Simon
--
================================
Simon Verona
Dealer Management Service Ltd
Stewart House
Centurion Business Park
Julian Way
Sheffield
S9 1GD
Tel: 0870 080 2300
Fax: 0870 735 0011
"Grumpy Aero Guy" <fb@xxxxxxxxxx> wrote in message
news:UZm4g.23735$P2.7486@xxxxxxxxxxxxxxxxxxxxxxxxx
corrrect you are.
Testing against the forst two octets should be sufficient to determine
routable vs. non routable.... aka internal/external.
NOW, if an internal network is configured to have an IP scheme with
ROUTABLE IPs ( which CAN be done --- WHY? I wouldn't know)... that would
make it a bit touchy.
--
Grumpy Aero Guy
"Cor Ligthert [MVP]" <notmyfirstname@xxxxxxxxx> wrote in message
news:%23HCKc6naGHA.5088@xxxxxxxxxxxxxxxxxxxxxxx
Terry,
AFAIK are there three ranges reserved for internal use
10.x.x.x
150.x.x.x
192.168.x.x
If I am not completely wrong than the first two should therefore be
enough.
Cor
"Terry Olsen" <tolsen64@xxxxxxxxxxx> schreef in bericht
news:ug3WninaGHA.4116@xxxxxxxxxxxxxxxxxxxxxxx
I'm writing an app that communicates with computers both inside and
outside my router. So I need to determine by the remote host's IP
address if I need to send them my LAN IP or my Internet IP. Someone
suggested AND'ing the IP and my Subnet Mask but I come up with this:
My IP: 192.168.0.14
Mask: 255.255.255.0
Result: 192.168.0.0
Should I just compare the first two octets? Or are there situations
where this would provide incorrect results?
.
- Follow-Ups:
- Re: At a loss figuring out if an IP is on LAN or INET
- From: aaron.kempf@xxxxxxxxx
- Re: At a loss figuring out if an IP is on LAN or INET
- References:
- At a loss figuring out if an IP is on LAN or INET
- From: Terry Olsen
- Re: At a loss figuring out if an IP is on LAN or INET
- From: Cor Ligthert [MVP]
- Re: At a loss figuring out if an IP is on LAN or INET
- From: Grumpy Aero Guy
- At a loss figuring out if an IP is on LAN or INET
- Prev by Date: Re: DWORDS ? LONG? - I need to create constants for the following
- Next by Date: Problem with FTP API and File Times
- Previous by thread: Re: At a loss figuring out if an IP is on LAN or INET
- Next by thread: Re: At a loss figuring out if an IP is on LAN or INET
- Index(es):
Relevant Pages
|