Jump to content
  • Advertisement
Sign in to follow this  
matt_j

Static IP on LAN question

This topic is 4336 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!