How does subnetting work?

Started by
1 comment, last by alvaro 13 years, 4 months ago
I'm trying to understand exactly how this crap works. So if you have an ip address like:

160.55.0.0 and the subnet mask is 255.255.0.0

if you change the subnet mask to 255.255.240.0 to accommodate the requirement of 10 subnets, what do you have to do to the ip address because bitwise AND will return 0 between 240.0 and 0.0.

And uhh...this might not be the most appropriate place for this, I dunno. ;o
They hated on Jeezus, so you think I give a f***?!
Advertisement
I'll move you to Multiplayer and Network Programming, which is probably a slightly better fit for this particular question. [smile]

- Jason Astle-Adams

It's relatively straight forward. These numbers can be used to determine if a particular IP address is in the subnet or not. The rule is

if ((IP_address & 255.255.0.0) == 160.55.0.0) {  // Yes, it's in the subnet}else {  // Not in the subnet}


In other words, only IP addresses of the form 160.55.xxx.yyy are in the subnet.

If you change the mask to 255.255.240.0, let's write it in binary to see what it really means: 11111111.11111111.11110000.00000000. So now IP addresses have to have the form 160.55.xxx.yyy, but with xxx between 0 and 15.

Do the bitwise AND by hand with several examples to see for yourself how it works.

This topic is closed to new replies.

Advertisement