tag:blogger.com,1999:blog-5554915078212081470.post-5688291487732379852008-03-03T02:38:00.000-06:002008-03-02T23:59:39.238-06:00IP subnettingThis really isn't that hard, but I had someone ask for help on one of the forums I participate in, and thought I'd share the answer here.<br /><br />The person needed to determine the following given an IP/Mask of <span style="font-weight: bold; color: rgb(255, 0, 0);">146.141.219.47/18</span><br /><ul><li>Subnet Mask</li><li>Network Address</li><li>First usable host address</li><li>Last usable host address</li></ul>The answer is to use binary math and boolean logic to solve the problems.<br /><br />/18 means there is an 18 bit subnet mask on that IP address. This is neither a Class C (24 bit subnet mask) or Class B (16 bits). Although, "Classes" are kind of obsolete these days. It's just an 18 bit subnet mask. Straightforward.<br /><br />In binary, it looks like this (decimal underneath):<br /><pre>11111111 11111111 11000000 00000000<br /> 255 255 192 0</pre><br /><br />To get the network address, you take the IP Address in binary, and do a boolean AND against the subnet mask. A boolean AND will only return a 1 where both numbers have a 1, and return a 0 everywhere else. <br /><br /><pre><br />11111111 11111111 11000000 00000000 <-- subnet mask 255.255.192.0<br />10010010 10001101 11011011 00101111 <-- IP Address 146.141.219.47<br />======== ======== ======== ========<br />10010010 10001101 11000000 00000000 <-- Network Address 146.141.192.0</pre><br /><br />The first usable host IP address is always the first IP after the network address, in this case, 146.141.192.1.<br /><br />To get the broadcast address, you simply change all of the non-masked bits from the network address (in this case, the last 14 bits) to 1.<br /><br /><pre>10010010 10001101 11111111 11111111 <-- Broadcast 146.141.255.255</pre><br /><br />You need to know the broadcast address to come up with the last usable host IP address, which is always one IP below the broadcast address. The last usable IP in the network for this example is 146.141.255.254.<div class="blogger-post-footer"><P>HiR Information Report is brought you you by <A HREF="http://edgeos.com">Edgeos</A>, Your Network Security Platform. We are proud members of the <A HREF="http://securitybloggers.net/">Security Bloggers Network</A>.</P>
<P>This content originally posted on <A HREF="http://www.h-i-r.net/">HiR Information Report</A>. Copyright © 1997-2009, HiR</P><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5554915078212081470-568829148773237985?l=www.h-i-r.net'/></div>Ax0nhttp://www.blogger.com/profile/12145109647562469601noreply@blogger.com2