Previous Thread
Next Thread
Print Thread
Rate Thread
#2295 04/01/03 06:18 PM
Joined: Mar 2002
Posts: 1,041
I
UGN Elite Poster
OP Offline
UGN Elite Poster
I
Joined: Mar 2002
Posts: 1,041
We were talking about this in IRC the other day so I thought I'd write up a explanation for anyone who would care to know a little more.

I'm going to assume here that you already know how binary works, and can perform some simple

converion either in your head or on paper. I'm also assuming that you know the difference

between a class A, B, and C IP address.

The purpose of a subnetting is to make more logical divisions (subnetworks) out of a given

IP address range. In a class A network, there are 126 useable networks, and 16777214 hosts

per network. Kinda ridiculous and defineatly not very useful. To address this problem the

practice of subnetting was put into use. Every host on every network must have an

appropriate subnet mask or it can not comunicated on the network. To acheive the additional

networks, bits are 'borrowed' from the host portion of the address.

Looking at IP addresses in the dotted decimal format, the network vs. hosts bits are broken

down like this:

class A -- N.H.H.H
Class B -- N.N.H.H
class C -- N.N.N.H

The network number for a network always has the hosts bits turned off (o). As well, the

address for every host on the network is when all host bits are turned on (1).

So, let's take a look at what exactly an IP address is. An IP address is a 32 bit binary

string that is used to identify a host on a network. For readibility's sake, this string is

commonly represented as a dotted decimal quad that looks something like:

192.168.69.132

But keep in mind, this is what it really looks like:

11000000101010000100010110000100

Well, this doesnt look fun at all now does it. That is what IP looks like to a router or a

host, so we must too.

Now let's look at a default subnet mask for our above example class C IP address:

255.255.255.0

Which in binary is:

11111111111111111111111100000000

To get the network address from these two numbers, the numbers are AND'ed together

11000000101010000100010110000100

A N D

11111111111111111111111100000000

E Q U A L

11000000101010000100010100000000

Convert this into our dotted decimal notation and we have:

192.168.69.0

This number is used by routing protocols to identify this network among other network on a

LAN or WAN. But what does this all mean? This means that our example IP belongs to the

132nd host on the network 192.168.69.0. it also means that there are a possible 254 hosts

on that same network.

But, what if the subnetmask was not 255.255.255.0? Let's say the subnet mask is

255.255.255.192 instead. Performing the AND'ing again we get:

11000000101010000100010110000100

A N D

11111111111111111111111110000000

E Q U A L

11000000101010000100010110000000

Whoa! In our dotted decimal that makes 192.168.69.128 as the network number! So now our

address is the 4th host on network 192.168.69.128, out of a possible 126. And because this

is now a subnetted address, the network is actually the second of two subnetworks.

As mentioed above, a class C address uses the final 8 bits to represent the host portion of

an address. With our example subnet of 255.255.255.192 we borrowed 2 bits, giving us two

usable subnets. The formula to figure out the useable hosts or subnets it to raise 2 to the

number of bits available and minus 2 ((2^n)-2)). With our example we have:

(2^2)-2

4-2

2

Giving us 2 useable subnets (the first is the network number, the last is the broadcast,

hence the minus 2. As well, when subnetting you may not borrow 1 bit, or leave 1 bit for

the host portion. At least two bits must occupy either network or host portion at all

times).

For the hosts we have 6 bits:

(2^6)-2

64-2

62

62 useable host addresses per subnet. Now wait a moment... With our default subnet we had

one network with two hundred and fifty-four hosts, now we have two networks with sixty-two

hosts per subnetwork? Where did the other 132 hosts addresses go?!?! This is the downside

to subnetting. While you lose available host addresses, the benefits of subnetting far

outweigh this and is well beyond how much detail I want to go into =�.

Let's looks at a little more complicated example. We want to find the network number, host

number for this IP, total number of subnets, and total number hosts:

IP: 24.67.85.144
Mask: 255.255.192.0

first we do a binary AND:

00011000010000110101010110010000

A N D

11111111111111111100000000000000

E Q U A L

00011000010000110100000000000000

Into dotted decinal we have a network number of 24.67.64.0. This means that our host is number

5520 on this network! To finish the question, it's a class A network so we borrowed 10 bits:

(2^10)-2

1024-2

1022 Subnets

And we left 14 bits in the host portion:

(2^14)-2

16384-2

16382 Hosts

Now that we can find a subnet, let's make some. Let's say we want to subnet the class B

address of 172.15.0.0 into a minimum of 325 subnetworks. Using the above formula:

(2^8)-2 = 254 too low

(2^9)-2 = 512 OK

So if we are to borrow 9 bits then our subnet mask is 255.255.255.128. But let's look at

how we arrive at our network numbers by using binary again. We start with the address of

172.15.0.0, which gives the following meaning to the bits:

NNNNNNNNNNNNNNNNSSSSSSSSSHHHHHHH

Because this is an assigned address, we cannot change the first two octets. knowing those

are constant we have a subnet range of 172.15.0 - 172.15.255 . in binary this is:

172.15.00000000 - 172.15.11111111

To get get our subnetwork numbers we count up the subnetwork bits in binary one at a time:

Binary -- Decimal

172.15.000000000|0000000 -- 172.15.0.0 (unuseable)
172.15.000000001|0000000 -- 172.15.0.128
172.15.000000010|0000000 -- 172.15.1.0
172.15.000000011|0000000 -- 172.15.1.128
172.15.000000100|0000000 -- 172.15.2.0
172.15.000000101|0000000 -- 172.15.2.128

to

172.15.111111011|0000000 -- 172.15.253.128
172.15.111111100|0000000 -- 172.15.254.0
172.15.111111101|0000000 -- 172.15.254.128
172.15.111111110|0000000 -- 172.15.255.0
172.15.111111111|0000000 -- 172.15.255.128 (unuseable)

And likewise, in any given subnetwork we count up each host bit to get the host numbers:

Binary -- Decimal

172.15.010101011|0000000 172.15.85.128 (Network)
172.15.010101011|0000001 172.15.85.129
172.15.010101011|0000010 172.15.85.130
172.15.010101011|0000011 172.15.85.131

to

172.15.010101011|111100 172.15.85.252
172.15.010101011|111101 172.15.85.253
172.15.010101011|111110 172.15.85.254
172.15.010101011|111111 172.15.85.255 (Broadcast)


And that is how we subnet!

Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
You forgot class d! the direct ip's! lol...


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
Joined: Mar 2002
Posts: 1,041
I
UGN Elite Poster
OP Offline
UGN Elite Poster
I
Joined: Mar 2002
Posts: 1,041
yeh, I left out the class e (reserved/experimental) as well. If you can tell me what exactly these have to do with subnetting I might even care too =�

Infinite


Link Copied to Clipboard
Member Spotlight
Phatal
Phatal
Houston, TX
Posts: 298
Joined: April 2004
Forum Statistics
Forums41
Topics33,840
Posts68,858
Average Daily Posts1
Members2,176
Most Online3,253
Jan 13th, 2020
Latest Postings
Where and how do you torrent?
by danni75 - 03/01/24 05:58 AM
Animation,
by JohanKaariainen - 08/15/19 01:18 AM
Blackbeard.....
by Gremelin - 10/03/18 07:02 PM
my old account still exists!
by Crime - 08/10/18 02:47 PM
Okay WTF?
by HenryMiring - 09/27/17 01:45 AM
The History Thread...
by Gremelin - 08/11/17 12:11 PM
My friend NEEDS your HELP!
by Lena01 - 07/21/17 12:06 AM
I'm having fun with this guy.
by gabithompson730 - 07/20/17 01:50 AM
I want to upgrade my phone
by gabithompson730 - 07/20/17 01:49 AM
Doom 3
by Cyrez - 09/11/14 08:58 PM
Amazon Gift Card Generator/KeyGen?te
by Gecko666 - 08/22/14 09:21 AM
AIM scene 99-03
by lavos - 09/02/13 08:06 AM
Planetside 2
by Crime - 03/04/13 07:10 AM
Beta Testers Wanted
by Crime - 03/04/13 06:55 AM
Hello Everyone
by Gremelin - 02/12/12 06:01 PM
Tracfone ESN Generator
by Zanvin Green - 01/18/12 01:31 PM
Python 3 issue
by Testing - 12/17/11 09:28 PM
tracfone airtime
by Drache86 - 07/30/11 03:37 AM
Backdoors and the Infinite
by ZeroCoolStar - 07/10/11 03:52 AM
HackThisZIne #12 Releaseed!
by Pipat2 - 04/28/11 09:20 PM
gang wars? l33t-wars?
by Gremelin - 04/28/11 05:56 AM
Consolidate Forums
by diggin2deep - 04/21/11 10:02 AM
LAN Hacking Noob
by Gremelin - 03/12/11 12:42 AM
Top Posters
UGN Security 41,392
Gremelin 7,203
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Likes Received
Ghost 2
Cyrez 1
Girlie 1
unreal 1
Crime 1
Powered by UBB.threads™ PHP Forum Software 7.7.5