Sign in to follow this  
matt_j

Static IP on LAN question

Recommended Posts

Hey, quick question. I have a small function to detect if a given IP address is located on a LAN, but I ran into a small issue: At my university, numerous computers are on a LAN, but have a static IP address (visible to the world). Is there another way, other than maybe using pings to detect if this type of computer is also on a local LAN? -I could also use broadcasting, I suppose. Effort... EDIT: your average LAN addresses are 192.168.xxx.xxx, but these are 129.xxx.xxx.xxx, and are visible via broadcasting.

Share this post


Link to post
Share on other sites
Virtually all computers are "on a LAN", that is, connected directly to a layer-2 switching device instead of a layer-3 bridge. Also, the definition of a "static IP address" has nothing to do with whether the IP address is "visible to the world". You seem to be confusing several concepts here. What is it you're actually trying to do?

Share this post


Link to post
Share on other sites
-Basically, I'm using lots of computers on a Lan.
-They have an internet IP, not a LAN IP (192.168 etc etc)
-They can talk to each other via broadcast

-What I'm asking is, in this situation, is there a direct way of detecting if these computers are connected on a "layer 2" switch, as you call it (I'm not an expert)

Share this post


Link to post
Share on other sites
Sure. All you need is your IP, their IP, and your netmask. If YOUR_IP & YOUR_NETMASK == THEIR_IP & YOUR_NETMASK, you're connected on the same LAN.

Example: Your IP is 129.128.159.51. Your netmask is 255.255.0.0. Their IP is 129.128.188.22. AND-ing the netmask to the IP addresses results in 129.128.0.0 (also known as your network address) and 129.128.0.0. They're the same, so you're connected.

Example: Your IP is 129.128.159.51. Your netmask is 255.0.0.0. Their IP is 136.44.14.183. AND-ing the netmask to the IP addresses results in 129.0.0.0 and 136.0.0.0. They're different, so you're not on the same LAN.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this