Monday, October 12, 2009

Subnetting

Basics:
Bit= 1 digit i/e: 1 or 0
Byte= 8 bits

Decimal Conversion Chart:
bit
8
7
6
5
4
3
2
1
value
128
64
32
16
8
4
2
1
subnet
128
192
224
240
248
252
254
255

2^7
2^6
2^5
2^4
2^3
2^2
2^1
2^0
Binary Calculations

decimal
binary
2^0
1
NOTE:
I have added an additional space between the 8 octets in this paper only to make the reading easier. These would not appear in real life.0000 0001
2^1
2
0000 0010
2^2
4
0000 0100
2^3
8
0000 1000
2^4
16
0001 0000
2^5
32
0010 0000
2^6
64
0100 0000
2^7
128
1000 0000

Available addresses – each bit can be a 1 or a 0 so each bit = 2 addresses
1 bit
Each bit added doubles the number of available addresses just as each bit removed halves the number of available addresses.2 addresses
2 bits
4 addresses
3 bits
8 addresses
4 bits
16 addresses
5 bits
Addressing formula: 2n = ___. Fill in the blank for the need and find for n – where n is the number of bits needed.32 addresses
6 bits
64 addresses
7 bits
128 addresses
8 bits
256 addresses

Binary counting per octet:
0000 0000
0
0000 0001
1
0000 0010
2
0000 0011
The number of available addresses is 256. this includes 0000 0000 .3
0000 0100
4
0000 0101
5
~~
~~
1111 1111
255

Network ID: ‘Area Code’ – all computers on a segment will share a single Network ID. All Network IDs in a network must be unique to that network.
Host ID: ‘Phone Number’ – all computers on a network segment must have a unique Host ID to that segment.

Here are three ways of finding out what class your allocation is in. Use whichever you find easiest.
1. Class A addresses begin with 0xxx, or 1 to 126 decimal. (127 is loopback)
2. Class B addresses begin with 10xx, or 128 to 191 decimal.
3. Class C addresses begin with 110x, or 192 to 223 decimal.
4. Class D addresses begin with 1110, or 224 to 239 decimal. (a.k.a multicast - you'll probably never see these)
5. Class E addresses begin with 1111, or 240 to 254 decimal. (or these)
v If the first bit is 0 it is a Class A address
v If the first two bits are 10 it is a Class B address
v If the first three bits are 110 it is a Class C address
v If the first four bits are 1110 it is a Class D multicast address
v If the first four bits are 1111 it is a Class E experimental address
First Byte
Class
Default (classful) Network Mask
1-126
"A"
255.0.0.0
128-191
"B"
255.255.0.0
192-223
"C"
255.255.255.0

Each TCP/IP host (i/e NIC card) needs at MINIMUM a unique IP address and a subnet mask, and to communicate off of the immediate subnet it also needs a default gateway.

Repeaters, bridges and switches forward broadcasts. Routers do not.
Physical segment = a port out of a router or between two routers.
Public addresses = an address bought or leased from INternic or ARIN (and then from ISP or a corporation)
Private address = 10.0.0.0 to 10.255.255.255; 17.16.0.0 to 17.32.255.255; 192.168.0.0 to 192.168.255.255
Example: if a corporation was given 152.77.0.0 the admin would hand out the last two octets as needed.

Converting the subnet mask to binary:
1s = the network portion or ‘mask’ and the 0s = the host portion
Remember! your subnet mask must always have contiguous bits!
i/e: 1111 1111.1111 1111.1111 1111.0000 0000 = default class C subnet mask

Network Address Ranges by Class IP network addresses are issued as follows:
Class
Range
Default Mask
Number of Addresses
Class A
1-127
255.0.0.0
2^24=16,777,216
Class B
128-191
255.255.0.0
2^16=65,536
Class C
192-223
255.255.255.0
2^8=256

So an address of 152.77.0.0 would have a potential of 65,536 hosts! On one subnet…ouch.
Here is a reason why we subnet. Create multiple physical segments to break up network.

152.77.0.0 = Network ID = 65,536
255.255.0.0 = Default Subnet Mask
N.N.H.H = Default Subnet Mask (we need to ‘borrow’ bits for the host section to add to the network section)
N.N. SNID (borrowed bits) .H = Custom Subnet Mask

Subnet Masks - Binary Representations
Decimal
Binary
.192
11000000
2 bits
.224
11100000
3 bits
.240
11110000
4 bits
.248
11111000
5 bits
.252
11111100
6 bits
.254
11111110
7 bits
.255
11111111
8 bits

ANDING
TCP/IP software uses a logical "AND" operation to find out what subnet an address belongs to. When a 0 is ANDed with either a 0 or a 1, the result is a 0. When a 1 is ANDed with a 1, the result is 1:
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1
Classful Subnetting Tables
Class B



# of bits
Subnet Mask
# Subnets
# Hosts
2
255.255.192.0
2
16382
3
255.255.224.0
6
8190
4
255.255.240.0
14
4094
5
255.255.248.0
30
2046
6
255.255.252.0
62
1022
7
255.255.254.0
126
510
8
255.255.255.0
254
254
9
255.255.255.128
510
126
10
255.255.255.192
1022
62
11
255.255.255.224
2046
30
12
255.255.255.240
4094
14
13
255.255.255.248
8190
6
14
255.255.255.252
16382
2
Class C



# Bits
Subnet Mask
# Subnets
# Hosts
0
255.255.254.0
0
510
1
255.255.255.0
1
254
2
255.255.255.192
2
62
3
255.255.255.224
6
30
4
255.255.255.240
14
14
5
255.255.255.248
30
6
6
255.255.255.252
62
2
7
255.255.255.255
255
1


CIDR (Classless Inter Domain Routing) Bits to Mask
Address Class
CIDR Value
Subnet Mask
Class A
/8
255.0.0.0

/9
255.128.0.0

/10
255.192.0.0

/11
255.224.0.0

/12
255.240.0.0

/13
255.248.0.0

/14
255.252.0.0

/15
255.254.0.0

/16
255.255.0.0
Class B
/17
255.255.128.0

/18
255.255.192.0

/19
255.255.224.0

/20
255.255.240.0

/21
255.255.248.0

/22
255.255.252.0

/23
255.255.254.0

/24
255.255.255.0
Class C
/25
255.255.255.128

/26
255.255.255.192

/27
255.255.255.224

/28
255.255.255.240

/29
255.255.255.248

/30
255.255.255.252

/31
255.255.255.254

/32
255.255.255.255




Additional example:
Subnetting Class C - most typical example: /28 "all zeroes, all ones" excluded. Mask is 11110000This table may be all you ever need to know, for many installations. This is a typical example and possibly the most common one. Because it is such a useful table, this is the only large one we will list in full.
Network part
Subnet.host
Host addresses
Broadcast Address
192.168.1.0
0000xxxx
192.168.1.1 to 192.168.1.14
192.168.1.15 - UNUSABLE - NETMASK ALL 0000's
192.168.1.16
0001xxxx
192.168.1.17 to 192.168.1.30
192.168.1.31
192.168.1.32
0010xxxx
192.168.1.33 to 192.168.1.46
192.168.1.47
192.168.1.48
0011xxxx
192.168.1.49 to 192.168.1.62
192.168.1.63
192.168.1.64
0100xxxx
192.168.1.65 to 192.168.1.78
192.168.1.79
192.168.1.80
0101xxxx
192.168.1.81 to 192.168.1.94
192.168.1.95
192.168.1.96
0110xxxx
192.168.1.97 to 192.168.1.110
192.168.1.111
192.168.1.112
0111xxxx
192.168.1.113 to 192.168.1.126
192.168.1.127
192.168.1.128
1000xxxx
192.168.1.129 to 192.168.1.142
192.168.1.143
192.168.1.144
1001xxxx
192.168.1.145 to 192.168.1.158
192.168.1.159
192.168.1.160
1010xxxx
192.168.1.161 to 192.168.1.174
192.168.1.175
192.168.1.176
1011xxxx
192.168.1.177 to 192.168.1.190
192.168.1.191
192.168.1.192
1100xxxx
192.168.1.193 to 192.168.1.206
192.168.1.207
192.168.1.208
1101xxxx
192.168.1.209 to 192.168.1.222
192.168.1.223
192.168.1.224
1110xxxx
192.168.1.225 to 192.168.1.238
192.168.1.239
192.168.1.240
1111xxxx
192.168.1.241 to 192.168.1.254
192.168.1.255 - UNUSABLE - NETMASK ALL 1111's
0's/1's restriction on host part: let's take one subnet from the table above:
Network part
Subnet.host
Host addresses
Broadcast Address
192.168.1.32
0010xxxx
192.168.1.33 to 192.168.1.46
192.168.1.47
Now, let's look at the individual hosts within that subnet:
Network part
Subnet . Host part
Host Address
192.168.1.32
0010.0000
UNUSABLE - HOST PART IS ALL 0's
192.168.1.33
0010.0001

192.168.1.34
0010.0010

192.168.1.35
0010.0011

192.168.1.36
0010.0100

192.168.1.37
0010.0101

192.168.1.38
0010.0110

192.168.1.39
0010.0111

192.168.1.40
0010.1000

192.168.1.41
0010.1001

192.168.1.42
0010.1010

192.168.1.43
0010.1011

192.168.1.44
0010.1100

192.168.1.45
0010.1101

192.168.1.46
0010.1110

192.168.1.47
0010.1111
UNUSABLE - HOST PART IS ALL 1's
Note what happens as the room for hosts gets smaller:This is the host table for a /30:
Network part
Subnet . Host part
Host Address
192.168.1.32
001000.00
UNUSABLE - HOST PART IS ALL 0's
192.168.1.33
001001.01

192.168.1.34
001010.10

192.168.1.35
001011.11
UNUSABLE - HOST PART IS ALL 1's
A /30 is particularly wasteful - 50% of the hosts are unusable. Similarly, a /26 is pretty bad, because 50% of the nets are unusable. a /28 is best because it lets you have (16 - 2) * (16 - 2) = 192 hosts.This would be the host table if a /31, if it existed:
Network part
Subnet . Host part
Host Address
192.168.1.32
0010000.0
UNUSABLE - HOST PART IS ALL 0's
192.168.1.33
0010000.1
UNUSABLE - HOST PART IS ALL 1's
What's wrong with this picture??? Well, you can't have a /31. Here's why...
We can have subnets of /26,/27,/28,/29,/30 - BUT NOT /25 or /31!This is a /30 (with sections removed for brevity):Mask is 11111100
Network part
Subnet.host
Host addresses
Broadcast Address
192.168.1.0
000000xx
192.168.1.1 to 192.168.1.2
192.168.1.3 - UNUSABLE - NETMASK ALL 000000's
192.168.1.4
000001xx
192.168.1.5 to 192.168.1.6
192.168.1.7
192.168.1.8
000010xx
192.168.1.9 to 192.168.1.10
192.168.1.11
192.168.1.12
000011xx
192.168.1.13 to 192.168.1.14
192.168.1.15
192.168.1.16
000100xx
192.168.1.17 to 192.168.1.18
192.168.1.19
192.168.1.20
000101xx
192.168.1.21 to 192.168.1.22
192.168.1.23
192.168.1.24 - 244
...
..............................
.............
192.168.1.248
111110xx
192.168.1.249 to 192.168.1.250
192.168.1.251
192.168.1.252
111111xx
192.168.1.253 to 192.168.1.254
192.168.1.255 - UNUSABLE - NETMASK ALL 111111's
So why not a /25????
Network part
Subnet.host
Host addresses
Broadcast Address
192.168.1.0
0xxxxxxx
192.168.1.1 to 192.168.1.126
192.168.1.127 - UNUSABLE - NETMASK ALL 0's
192.168.1.128
1xxxxxxx
192.168.1.129 to 192.168.1.254
192.168.1.255 - UNUSABLE - NETMASK ALL 1's
When the netmask is only one bit, it can't help but being all zeroes or all ones.
And why not a /31?
Network part
Subnet.host
Host addresses
Broadcast Addresses (0's and 1's)
192.168.1.0
0000000x
192.168.1.0? to 192.168.1.1?
192.168.1.0 - UNUSABLE - NETMASK 000000's192.168.1.1 - UNUSABLE - NETMASK 000000's
192.168.1.2
0000001x
192.168.1.2? to 192.168.1.3?
192.168.1.2 - UNUSABLE - Broadcast 0's192.168.1.3 - UNUSABLE - Broadcast 1's
192.168.1.4 - 250
...
..............................
..........................
192.168.1.252
1111110x
192.168.1.252 to 192.168.1.253
192.168.1.252 - UNUSABLE - Broadcast 0's192.168.1.253 - UNUSABLE - Broadcast 1's
192.168.1.254
1111111x
192.168.1.254 to 192.168.1.255
192.168.1.254 UNUSABLE - NETMASK 111111's192.168.1.255 UNUSABLE - NETMASK 111111's

No comments: