Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Cisco Community
- :
- Technology and Support
- :
- Networking
- :
- Network Management
- :
- Determining whether two addresses are o...

3170

Views
0

Helpful
4

Replies
Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-11-2011
12:54 AM

11-11-2011
12:54 AM

Hello Everyone,

What is the formula or mathimatical operation to determine whether two addresses are on the same subnet or not?

I know that I can use AND operation to do this but this is time consuming, also I know the formula in MS Press book which is :

f1 = [K1 / (256-d)] - any reminder

f2 = [K2 / (256-d)] - any reminder

Where K1 and K2 are the respective value of the octet in each IP address whose position corresponds to d

and "d" is the modrange value octet in the subnet mask.

didn't get it right

lets take this example to understand:

I need to determine whether these rwo IP addresses are in the same subnet

192.168.0.180 180 is K1

192.168.0.192 192 is K2

with net massk of 255.255.255.224 224 is d

using this information we will see

f1 = [180 / (256-224)] = 180 / 32 = 5.625

f2 = [192 / (256-224)] = 180 / 32 = 6

f1 is not equal to f2 and so they are not in the same subnet!

Well this formula works sometimes but others not!

now lets do the traditional way of determining whether these rwo IP addresses are in the same subnet:

Netmask : 255.255.255.224

Binary : 11111111 11111111 11111111 11110000

The increment value is 16 therefore:

192.168.0.16 192.168.0.31

192.168.0.32 192.168.0.47

192.168.0.48 192.168.0.63

192.168.0.64 192.168.0.79

192.168.0.80 192.168.0.95

192.168.0.96 192.168.0.111

192.168.0.112 192.168.0.127

192.168.0.128 192.168.0.143

192.168.0.144 192.168.0.159

192.168.0.160 192.168.0.175

192.168.0.176 192.168.0.191 here is the first IP Subnet ( 180 )

192.168.0.192 192.168.0.207 here is the secons IP Subnet and it is the network ID itself ( 192 )

192.168.0.208 192.168.0.223

192.168.0.224 192.168.0.239

Now we know that they are not in the same subnet!

The Question IS, How can I jump directly to the desired range without writing all of these ranges to get to the desired range ?????

I saw a vedio before and the guy said that I can use the number and make it power of 10 to jump directly to the Range ??? but I can't find the Video

Does anyone has idea how to do this

Thank you very much

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-11-2011
02:41 AM

11-11-2011
02:41 AM

wouldn't this give you what you want:

if the devision has a rest (module not eqals 0) # e.g. 180/32 = 5.625

take just the integer and multiply it with [256 - d] # 5 * 32 = 160

it gives you the network directly: 192.168.0.160

but you made a little mistake - just a bit-swap..

Netmask : 255.255.255.224

is

Binary : 11111111 11111111 11111111 11100000

and not

Binary : 11111111 11111111 11111111 11110000

therefore, the increment value is 32 not 16 - and that is what you get when you subtract 224 from 256:

256 - 224 = 32 (the number of addresses for each subnet)

if the modulo equals 0 you have the first IP of the network directly;

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-11-2011
02:41 AM

11-11-2011
02:41 AM

wouldn't this give you what you want:

if the devision has a rest (module not eqals 0) # e.g. 180/32 = 5.625

take just the integer and multiply it with [256 - d] # 5 * 32 = 160

it gives you the network directly: 192.168.0.160

but you made a little mistake - just a bit-swap..

Netmask : 255.255.255.224

is

Binary : 11111111 11111111 11111111 11100000

and not

Binary : 11111111 11111111 11111111 11110000

therefore, the increment value is 32 not 16 - and that is what you get when you subtract 224 from 256:

256 - 224 = 32 (the number of addresses for each subnet)

if the modulo equals 0 you have the first IP of the network directly;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-11-2011
03:30 AM

11-11-2011
03:30 AM

Determining whether two addresses are on the same subnet formula

OMG it's not a small mistake I did, it's BIG which could ruin the whole question lol

sorry about that

Very good Martin it is easier now for me

Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-11-2011
04:38 AM

11-11-2011
04:38 AM

Determining whether two addresses are on the same subnet formula

In addition to Martin's correct answer regarding appllication of the formula you cited, you may also want to consider a tool that you can run for this. Solarwinds offers a free (ad-supported) version of their Subnet Calculator that you can download to your desktop. Here is a link to it. It's also included (without ads) in their paid Engineer's Toolset product.

Of course there are also web sites with tables and such.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-11-2011
05:59 AM

11-11-2011
05:59 AM

Determining whether two addresses are on the same subnet formula

Thanks a lot mklemovitch

The software is awesome but I needed this information for the Cisco exam and Microsoft infrastructure exam too, therefore the calculator would be useful for me only as a helper to chk my results but it's very helpful.

Latest Contents

Created by pbagga
on 10-15-2019
05:23 PM

0

0

0

0

How to configure Wide Area Bonjour in SD-Access (SDA) with Cisco DNAC 1.3.1
<placeholder>

Created by pbagga
on 10-15-2019
05:15 PM

0

0

0

0

How to do host on-boarding in SD-Access
<placeholder>

Created by pbagga
on 10-15-2019
05:13 PM

0

0

0

0

How to provision devices in SD-Access
<placeholder>