Re: At a loss figuring out if an IP is on LAN or INET

Tech-Archive recommends: Fix windows errors by optimizing your registry



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?








.



Relevant Pages

  • Re: subnetting confusion
    ... >> subnet mask is or is not necessary. ... >existing network by simply changing the mask. ... >I have purchased a set of 8 static IPs. ...
    (microsoft.public.windows.server.networking)
  • Re: TCP/IP question,PLEASE!
    ... mask is and how to apply it to IP address. ... a subnet is. ... For hosts to be in the same subnet, they must have the same network address. ... A host address's components: ...
    (microsoft.public.windowsxp.general)
  • Re: ipconfig question
    ... or proxy server might be from a regular user on the subnet? ... > network admin more than likely has a NAT system set up. ... > Internet. ... The NAT server, ...
    (microsoft.public.win2000.networking)
  • Re: Blocking Yahoo Messenger With Firewall??
    ... >info from the Feds and states for info on making policies, ... >them are users that would be using the Internet. ... packets from anywhere except the subnet where the authorized users are. ... have access to the rest of the company network, ...
    (alt.computer.security)
  • Re: LAN IP addresses
    ... some operating systems that the lowest and highest _subnet_ were ... "outside", you probably have no idea what mask may be used on the LAN, ... and I believe it should not matter to any network equipement either. ...
    (comp.os.linux.networking)