Subnetting

painveilNetworking and Communications

Oct 24, 2013 (3 years and 11 months ago)

69 views

Subnetting
Computer Networks
A network with two levels of
hierarchy (not subnetted)
A network with three levels of
hierarchy (subnetted)
Why Subnet?

To break the network down into pieces, each
of which can be addressed separately.

Efficiency of assigning addresses: Without
subnetting for example, a network with two nodes
uses an entire class C network address, thereby
wasting 253 perfectly useful addresses; a class B
network with slightly more than 255 hosts wastes
over 64,000 addresses.

Assigning one network number per physical network,
therefore, uses up the IP address space potentially
much faster than we would like.

Assigning many network numbers has another
drawback that becomes apparent when you think
about routing.
Why Subnet?

Assigning many network numbers has another drawback that
becomes apparent when you think about routing. Hence, the
more network members there are in use, the bigger the
forwarding tables get. Big forwarding tables add cost to
routers, and they are potentially slower to search than smaller
tables for a given technology, so they degrade router
performance.

Organization of IP address space

Reduces broadcasts

Controls network traffic efficiently

Can provide low level security with access lists on
the router

Used in different physical media
6
Classful IP Addressing
Class A:
0
Netid (7 bits)
Hostid (24 bits)
Class C:
Class D:
Class E:
Class B:
Netid (14 bits)
1
0
Hostid (16 bits)
1
1
0
Netid (21 bits)
Hostid (8 bits)
1
1
1
0
Multicast address (24 bits)
1
1
1
1
Reserved for future use (24 bits)
Subnetting a Default Class C
Network Address: 200.129.41.0

Default Class C address is divided into
network and host portions as follows:
N . N . N . H

To subnet we “borrow” bits from the host
portion of the address (8 bits for Class C)
N . N . N . x
x
x
x
x
x
x
x

Borrowing
n
bits yields 2
n
–2subnets.

Leaving
n
bits yields 2
n
–2hosts.

For a class C, we can borrow from 2 to 6 bits.

Why not 1 bit? (How many usable subnets?)

Why not 7 bits? (How many usable hosts?)
Subnetting a Default Class C
Network Address: 200.129.41.0

Suppose we need 14 usable subnets, how
many bits do we borrow?

Remember, borrowing
n
bits give us:

2
n
–2 subnets

Try borrowing 3 bits (
n
= 3)
:

23
–2= 8 –2
= 6 usable subnets (not enough)

Try borrowing 4 bits

24
–2= 16 –2
= 14 usable subnets (enough)
Subnetting a Default Class C
Network Address: 200.129.41.0

Write it with the network octet in binary:
200.129.41.00000000
break here

Borrowing 4 bits yields 14 usable subnets

How many usable hosts per subnet?

Same formula as subnets (2
n
–2
)

4 host bits (
n
= 4)

24
–2 = 16 –2
= 14 usable hosts per subnet
subnet bits
host bits
Subnetting a Default Class C
Network Address: 200.129.41.0

Examples:

First usable 200.129.41.0001 ^
0000
subnetaddress:200.129.41.16

First usable host200.129.41.0001 ^
0001
onthe first subnet:200.129.41.17

Second usable host200.129.41.0001 ^
0010
onthe first subnet:200.129.41.18
.
.
.

Last usable host200.129.41.0001 ^
1110
on the first subnet:200.129.41.30

Broadcast address200.129.41.0001 ^
1111
for the first subnet:200.129.41.31
Subnetting a Default Class C
Network Address: 200.129.41.0

Examples:

Second usable 200.129.41.0010 ^
0000
subnetaddress:200.129.41.32

Third usable 200.129.41.0011 ^
0000
subnetaddress:200.129.41.48

Fourth usable 200.129.41.0100 ^
0000
subnetaddress:200.129.41.64
.
.
.

Last usable 200.129.41.1110 ^
0000
subnetaddress:200.129.41.224
The Subnet Mask: How the
Router Determines the Subnet

The subnet mask (in binary) has:

all ones in the network and subnet portion of
the address

all zeros in the host potion of the address

The subnet mask for the previous example is:
255.255.255. 240
255.255.255.1111^
0000 (128 + 64 + 32 + 16 =240)

ANDing this mask with any valid host address on
the network will always yield the subnet address
for that host.
The Subnet Mask: How the
Router Determines the Subnet

Example (our subnet mask is 255.255.255.240)
IP host address:200.129. 41.23
Last octet to binary:200.129. 41.00010111
AND subnet mask:255.255.255.11110000
200.129.41.0001 0000
Subnet Address:200.129. 41.16
So the host address 200.129. 41.23is on the
200.129.41.16subnet.
Subnetting a Default Class B
Network Address: 132.178.0.0

Default Class B address is divided into
network and host portions as follows:
N . N . H. H

To subnet we “borrow” bits from the host
portion of the address (16 bits for Class B)
N . N . x
x
x
x
x
x
x
x
. x
x
x
x
x
x
x
x

For a class B, we can borrow from 2 to 14
bits.
Subnetting a Default Class B
Network Address: 132.178.0.0

Suppose we need 80 usable subnets, how
many bits do we borrow?

Remember, borrowing
n
bits give us:

2
n
–2 subnets

Try borrowing 6 bits (
n
= 6)
:

26
–2= 64 –2
= 62 usable subnets (not enough)

Try borrowing 7 bits

27
–2= 128 –2
= 126 usable subnets (enough)
Subnetting a Default Class B
Network Address: 132.178.0.0

Write it with the network octets in binary:
132.178.0000000 0.00000000
break here

Borrowing 7 bits yields 126 usable subnets

How many usable hosts per subnet?

Same formula as subnets (2
n
–2
)

9 host bits (
n
= 9)

29
–2 = 512 –2
= 510 usable hosts per subnet
subnet bits
host bits
Subnetting a Default Class B
Network Address: 132.178.0.0

Examples:

First usable 132.178.0000001 ^
0.00000000
subnetaddress:132.178.2.0

First usable host132.178.0000001 ^
0.00000001
onthe first subnet:132.178.2.1

Second usable host132.178.0000001 ^
0.00000010
onthe first subnet:132.178.2.2
.
.
.

Last usable host132.178.0000001 ^
1.11111110
on the first subnet:132.178.3.254

Broadcast address 132.178.0000001 ^ 1.11111111
for the firstsubnet:132.178.3.255
Subnetting a Default Class B
Network Address: 132.178.0.0

Examples:

Second usable
132.178.0000010
^
0.00000000
subnet address:
132.178.4.0

Third usable
132.178.0000011
^
0.00000000
subnet address:
132.178.6.0
.
.
.

Ninety-first usable
132.178.1011011
^
0.00000000
subnet address:
132.178.182.0
.
.
.

Last usable
132.178.1111110
^
0.00000000
subnet address:
132.178.252.0
Subnetting a Default Class B
Network Address: 132.178.0.0

The subnet mask for this example is:
255.255.254.0
255.255.1111111
^
0.00000000

ANDing this mask with any valid host address
on this network will always yield the subnet
address.
Subnetting a Default Class B
Network Address: 132.178.0.0

Example:
IP host address:
132.178.119.112
Last octets to binary:
132.178.0111011 ^
1.01110000
AND subnet mask:
255.255.1111111
^
0.00000000
132.178.0111011 ^
0.00000000
Subnet Address:132.178.118.0

Which subnet is this. How can you tell?
Calculating: Class C, Example
Different Point of View
Network address = 192.168.10.0
Subnet mask = 255.255.255.192
Just answer the five questions:
1) How many subnets? Since 192 is 2 bits on
(11000000), the answer is 22
–2 = 2
2) How many hosts per subnet? We have 6
host bits off (11000000), so the equation
would be 26
–2 = 62
hosts.
Example (cont.)
3) What are the valid subnets?
256-192 = 64, which is the first subnet and
also the block size. Keep adding the block
size to itself until you reach the subnet mask.
64 + 64 = 128. 128 + 64 = 192, which is
invalid because it is the subnet mask (all
subnet bits turned on). Our two valid subnets
are, then, 64 and 128.
Example (cont.)
4) What’s the broadcast address for each
subnet?
The number right before the value of the next
subnet is all host bits turned on and equals
the broadcast address.
5) What are the valid hosts?
These are the numbers between the subnet
and broadcast address.
Example Final Result
Network = 192.168.10.0
Mask = 255.255.255.192
First
subnet
Last
subnet
Subnets (do first)64128
Hosts (do last)65 -126129 -190
Broadcast address (do
second)
127191
Calculating Class B Addresses,
Example
Network address = 172.16.0.0
Subnet mask = 255.255.192.0
Answer the five questions:
1)
Subnets? 22
–2 = 2. (192 = 11
000000)
2)
Hosts? 214
–2 = 16,382. (6 bits in the third
octet, and 8 in the fourth.)
3)
Valid subnets? 256 –192 = 64.
64 + 64 = 128. (these are the 2 subnets as
stated in question 1.)
Class B, Example (cont.)
4) Broadcast address for each subnet?
See table.
5) Valid hosts? See table.
FirstNext(Last)
Subnets172.16.64.0172.16.128.0
Hosts
172.16.64.1 –
172.16.127.254
172.16.128.1 –
172.16.191.254
Broadcast172.16.127.255172.16.191.255
Subnetting in Your Head, Class B
Q: What subnet and broadcast address is
the IP address 172.16.10.33
255.255.255.224 a member of?
A: 256 –224 = 32. 32 + 32 = 64.
33 is between 32 and 64. However,
remember that in Class B addresses the
third octet is considered part of the subnet,
so the answer would be the 10.32 subnet.
The broadcast is 10.63, since 10.64 is the
next subnet.
In Your Head, Class B
Q: What subnet and broadcast address is the IP
address 172.16.90.66, 255.255.255.192 a
member of?
A: 256 –192 = 64. 64 + 64 = 128. The subnet is
172.16.90.64. The broadcast must be
172.16.90.127, since 90.128 is the next
subnet.
Subnetting Class A Addresses

Same procedure as with Class B and Class C
only you must take into account the 8
additional bits from the second octet.
Class A, Example
Network 10.0.0.0
Subnet mask 255.255.0.0 ( /16 = 16 bits on)
1)
Subnets?
28
-2 = 254.
2)
Hosts? 216
–2 = 65,534
.
3)
Valid subnets? 256 –255 = 1, 2, 3, etc. (all
in the second octet). The subnets would be
10.0.0.0, 10.2.0.0, 10.3.0.0, etc., up to
10.254.0.0.
Class A, Example (cont.)
4) Broadcast address for each subnet?
10.1.255.255, 10.2.255.255, etc., up to
10.254.255.255.
5) Valid hosts? See table.
FirstNext…Last
Subnet
10.1.0.010.2.0.0…10.254.0.0
Hosts
10.1.0.1 –
10.1.255.254
10.2.0.1 –
10.2.255.254

10.254.0.1 --
10.254.255.254
Broad-
cast
10.1.255.25510.2.255.255…10.254.255.255