473,321 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

determine if 2 IP's are on the same subnet?

I'm looking for a function to return true/false depending on if two supplied
IP's (as strings) are in the same subnet (also supplied).
Im getting nowhere fast unfortunately - I know the theory behind it, but I
have no idea on how to actually implement it!
I have split my supplied 3 IP's into 4 numbers each, but past that I'm
stuck - on paper I would convert them to binary and write down all the 1's
and 0's then figure it out, but in code...?
Thanks
James
Nov 21 '05 #1
1 2392
You need to use the "and" function between each of the 4 octects in the ip
and the equilavalent octect in the net mask to get the "network" address.
If the network address is the same for the two ip's then they are the same
network.

Hope this helps..

Regards
Simon

"JamesB" <ja***@spamblows.puffle.co.uk> wrote in message
news:43***********************@news.zen.co.uk...
I'm looking for a function to return true/false depending on if two
supplied IP's (as strings) are in the same subnet (also supplied).
Im getting nowhere fast unfortunately - I know the theory behind it, but I
have no idea on how to actually implement it!
I have split my supplied 3 IP's into 4 numbers each, but past that I'm
stuck - on paper I would convert them to binary and write down all the 1's
and 0's then figure it out, but in code...?
Thanks
James

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dan | last post by:
Does anybody know how to control the source IP address (IPv4) when using the urllib2 library? I have a Linux box with several IP addresses in the same subnet, and I want to simulate several...
2
by: Manoj Nair | last post by:
Hi, Is there a way by which the IP address of a terminal can be set through code. thanks in advance Manoj
19
by: Frederik | last post by:
Hi all, Situation: - 2 computers behind router/switch; - dhcp enabled on router; - computer name 1 = cpuA (WinXP Pro); - computer name 2 = cpuB (WinXP Home); - cpuA and cpuB can access each...
3
by: billie | last post by:
Hi all. I'm searching for a module that permits me to low-level interact with ethernet interfaces of my system. I would like to determine at least the first of the followings values: 1 - IP...
20
by: Terry Olsen | last post by:
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. ...
9
by: =?Utf-8?B?SG93YXJkIFNtaXRo?= | last post by:
I am using VC++ 6.0 (with SP5 installed). When using WinXP this is with SP2 installed. I am developing an instrumentation system comprising a set of networked PCs connected using TCP/IP TCP links....
3
by: Smokey Grindel | last post by:
Is there a way to check if an IP address is in a subnet range? say I have the IP 10.10.0.0 and a subnet of 255.255.0.0 and am given the IP 10.10.50.1 and want to verify that it is in that...
2
by: nussu | last post by:
Hi , I need to find a subnet mask number for a given IP Address number. I have two textbox's once enter the ip address in first textbox i need to get subnet mask number for that ip address in...
1
by: =?Utf-8?B?Q2FybG9z?= | last post by:
Guys, I have a little problem here. I have an AD domain with one DC and 2 other member servers and when I go to My Network Places and browse the network, I can seamless see a list of all...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.