Subnet Addresses - Free Stuff Jamaica

advertisement
1
Subnet Addresses
Lesson Objectives
In this lesson, you will:


State the purpose of subnetting.
State the function of a subnet mask.
Introduction
To use your addresses, you need to understand subnetting. Subnetting allows you to create multiple,
logical networks that exist within a single Class A, B, or C network. If you don't subnet, you can only
use one network from your Class A, B, or C network. Unless you are assigned many major networks,
you really need to subnet.
Each data link on a network must be a unique subnet, with every node on that link being a member of
the same subnet. For serial interfaces, you need one subnet for the circuit or wire. Both ends of the
serial connection are in the same subnet.
A subnet mask is defined for each IP address. The subnet mask identifies which portion of the four
octets is used to identify the data link, with the remaining bits identifying the node.
2
Let's use these two addresses for some examples: 171.68.3.3 and 171.68.2.3. If the subnet mask is
255.255.255.0, the first 24 bits are masked, so the router compares the first three octets of the two
addresses. Because the masked bits are not the same, the router knows that these addresses belong to
different subnets.
If the subnet mask is 255.255.0.0, the first 16 bits are masked, so the router compares the first two
octets of the two addresses. Because the masked bits are the same, the router knows that these
addresses belong to the same subnet.
Nodes and routers use the mask to identify the data link on which an address resides. For instance,
imagine that San Francisco proper is a Class B network and the streets are subnets. Each street must
have a unique name. How would the postal service deliver a letter or find the correct destination if two
Lombard Streets existed? Each house number can be thought of as a unique identifier for that street.
The house numbers can be duplicated on other streets. For example, 33 Market Street is not the same
as 33 Lombard Street, as shown in the figure below.
Unique identifiers.
Sometimes you need to perform a logical AND operation to determine what subnet your node is in.
Performing an AND operation means that anytime you AND a 0 value to another 0 or a 1 value, the
result is 0. Only a 1 ANDed with another 1 value results in a 1 value. Here's how it works: 0 AND 0 IS
0, 0 AND 1 IS 0, or 1 AND 1 IS 1
Now let's compare our sample addresses (171.68.3.3 and 171.68.2.3) against the subnet mask
255.255.240.0. We need to compare the binary representation of the third octet of the mask with the
binary representation of the third octets of the addresses. To do this, we'll perform a logical AND
operation on the corresponding bits in each octet.
The masked bits are those that are "turned on," or are a 1 in the mask. Because the masked bits in both
addresses are the same, the router knows these addresses belong to the same subnet.
3
Subnet Masks
A subnet mask allows you to convert a single Class A, B, or C network into multiple networks. With a
subnet mask, you can create an extended network prefix that adds bits from the host number to the
network prefix. For example, a Class C network prefix always consists of the first three octets of the IP
address. But a Class C, extended network prefix uses part of the fourth octet as well.
Subnet masking is easier to understand if you use binary notation instead of dotted decimals. The bits
in the subnet mask and the Internet address have a one-to-one ratio. The bits of the subnet mask are set
to 1 if the corresponding bit in the IP address is part of the extended network prefix. The bits in the
mask are set to 0 if the bit is part of the host number.
For example, if you have the Class B address 129.10.0.0 and you want to use the entire third octet as
part of the extended network prefix instead of the host number, you need to specify a subnet mask of
11111111.11111111.11111111.00000000. This subnet mask converts the Class B address into the
equivalent of a Class C address, where the host number consists of the last octet only. If you want to
use only part of the third octet for the extended network prefix, then specify a subnet mask like
11111111.11111111.11111000.00000000, which uses only five bits of the third octet for the extended
network prefix.
You can write a subnet mask as a dotted decimal mask or as a /bits ("slash bits") mask. In the first
example, for a dotted decimal mask, you convert each binary octet into a decimal number:
255.255.255.0. For a /bits mask, you add the number of 1s: /24. In the second example, the decimal
number is 255.255.248.0 and the /bits mask is /21.
Example 1: Class B
Let's use a Class B address to illustrate how subnetting works. Let's say you are assigned the Class B
address 172.16 from the NIC. First, determine how many subnets you need, and how many nodes per
subnet you need to define. A typical (and easy-to-use) Class B subnet mask would be eight bits.
Because the third octet is the first "free" octet for Class B, you will start there. Thus, an eight-bit
subnet mask is 255.255.255.0. This means you have 254* subnets available and 254 addresses for
nodes per subnet.
4
Example 2: Class B
Now let's take this example: you have just assigned an interface the address 172.16.10.50 with a mask
of 255.255.255.0. What subnet is it in? First, represent the bits in binary. For Class B, you start with
the third octet, because octets 1 and 2 are fixed. This is illustrated in the figure below.
This address is in subnet 10 (172.16.10.0). Valid addresses for subnet 10 are 172.16.10.1 through
172.16.10.254. Address 172.16.10.255 is the broadcast address for this subnet. According to the
standard, any host ID consisting of all 1s is reserved for broadcast.
TIP: You should not use subnet 0 or a subnet of all 1s. An all 1s subnet mask is also your
broadcast address. You can configure this, but it is neither proper nor recommended to
make your subnet the same as your broadcast address. Subnet 0 is also not recommended;
however, Cisco will allow the use of subnet 0 with the IP subnet 0 command.
Example 3: Class B
Let's say you need more subnets than 254. (Remember this is the maximum number of subnets in a
single octet.) Staying with our Class B address, let's configure an 11-bit subnet. This means we'll use
all eight bits from our third octet and the first three bits from the fourth octet. The subnet mask is now
255.255.255.224 (128 + 64 + 32 = 224). Now you need to determine in what subnet the following
address is: 172.16.10.170 255.255.255.224. First, denote the address in binary representation (just
octets 3 and 4 for a Class B address) like the figure below.
The address here is in subnet 172.16.10.160. The valid addresses for this subnet are 172.16.10.161
through 172.16.10.190 (172.16.10.191 is the broadcast address). As soon as you hit 10.192, the bits in
the subnet change and you move into subnet 10.192.
5
Example 4: Class B
Let's take an example where the mask is shorter than one octet. Now we want only a few subnets, but
need many hosts per subnet. We'll use a three-bit subnet mask. Now we have: 172.16.65.170
255.255.224.0. (The mask is now the first three bits of the third octet.) What subnet is this address in?
See the figure below.
The subnet here is 172.16.64.0. The range of addresses that would fall into subnet 64 would be
172.16.64.1 through 172.16.95.254, with 172.16.95.255 as the broadcast address. The next subnet
would be 172.16.96.0. Class A and Class C map out exactly as Class B. The only differences are at
which octet subnetting starts and how many octets you can use for subnetting.
Example 5: Class C
Suppose the NIC assigned the address 192.1.10. You must use the fourth octet for your subnetting
needs. Let's use a four-bit subnet mask, shown in the figure below, and map out the following address:
192.1.10.200 255.255.255.240.
Address 192.1.10.200 is in subnet 192. The valid range of addresses in this subnet would be
192.1.10.192 through 192.1.10.206, with .207 as the broadcast address. The next subnet would be .208.
Keeping the same subnet mask, you can choose different addresses to be in different subnets. For
instance, address 192.1.10.17 255.255.255.240 is in subnet 16, and therefore, has another unique
subnet address, with valid addresses in the range of 192.1.10.17 through 192.1.10.30.
6
Subnet Mask Formatting
All classes of IP addresses have a default mask, often referred to as the netmask. The default netmasks
are as follows:






Class A: Network mask 255.0.0.0
Class A: 0.255.255.255 host bits
Class B: Network mask 255.255.0.0
Class B: 0.0.255.255 host bits
Class C: Network mask 255.255.255.0
Class C: 0.0.0.255 host bits
These masks are sometimes referred to as subnet masks, although technically this is not accurate. They
are really network masks. These masks only cover the range of bits reserved by default for the class of
address in question. The concept of a subnet mask is "to further subdivide a (major) network into
smaller (sub) networks." Hence, the terms are subnetwork and subnetwork mask, which are usually
shortened to subnet and subnet mask, respectively. Most people use the term subnet mask when
referring to either a network mask or a subnet mask. The next paragraphs explain what subnet masks
are and how they are used.
The network addresses previously discussed represent only one physical network. If you have all of
your hosts connected to the same piece of physical network equipment, such as an Ethernet 10BaseT
hub, you only need one network address. In this case, you could decide to use 125.0.0.0 as your
network address and assign host addresses from 125.0.0.1 to 125.255.255.254.
You can't use 125.255.255.255 because this is the address for all hosts. Every host in the 125.0.0.0
network receives any packets with this address. This is otherwise known as the broadcast address for
network 125.0.0.0. It requires that all digits in the second, third, and fourth octets be set to 1. The
broadcast address for a Class B address, such as 171.54.0.0, is 171.54.255.255. The broadcast address
for a Class C network, such as 220.34.145.0, is 220.34.145.255.
If you have hosts in two or more locations and a router connects the locations, you cannot use the
125.0.0.0 address in more than one location. Systems running IP consider the portion of the address
covered by the netmask as the "network" address and consider the remainder of the address as the host
portion. Each network must be unique because that is how systems such as routers (which connect
physical networks together and provide Layer 3 connectivity) determine where the IP networks are
located.
Consider a router with two Ethernet ports, 0 and 1. If the IP address on port 0 is 125.0.0.1 and the IP
address on 1 is 125.0.0.2, the router could not determine which interface a host with the IP address of
125.0.0.3 could reach using only Layer 3 information. The router only stores the network portion of the
address in its routing table (in this case, 125.0.0.0).
The routing table is the database the router uses to track all available networks. Looking at a packet
destined for 125.0.0.3, the router discovers that it is a host system on the 125.0.0.0 network. The router
then queries its routing table to determine which interface it knows about network 125.0.0.0. In this
example, the router discovers that both Ethernet 0 and Ethernet 1 have connections to 125.0.0.0. The
only logical conclusion the router can reach is that both interfaces are actually connected to the same
physical network. In this case, the router can choose either interface over which to forward the packet.
7
The other choice is to send two copies of the packet - one over each interface. Sending duplicate
packets is usually not a good idea. They waste processing power on the system receiving them, so the
router is likely to randomly select one of the interfaces. If 125.0.0.3 is connected to the physical
network the router selects, the packet is received. If it is not, the packet is not received.
With the exception of parallel WAN links using HDLC encapsulation, Cisco routers do not allow the
same network address to be applied to more than one interface. This also applies to subnets.
Think about telephone area codes in the U.S. phone system. Each area code must be unique.
Otherwise, the phone system would not be able to deliver the calls successfully.
The host portions of an address can be the same on different networks. Just as the phone system allows
for numbers such as 408-555-1212 and 650-555-1212, IP networks allow for addresses such as
10.1.2.3 255.0.0.0 and 11.1.2.3 255.0.0.0. The phone system routes the call based on the area code and
lets the local office keep track of its available numbers (telephones). The routers in an IP network route
IP packets based on their network addresses and let the final router in the path deliver the packet to its
final destination (IP end system). There are two solutions to this problem. You could select a different
network address for each location by using the default network mask for each address. In this case, you
could use 126.0.0.0 and 130.0.0 for the next two locations. Remember that 127.0.0.0 and 128.0.0.0 are
reserved. Or you could use subnetting. In this case, you need to come up with a subnet mask. What you
are basically doing is creating subnetworks from a major network.
Because a Class A address uses the first octet as the network portion and the final three octets as host
bits, the only way to create additional networks from the original network address is to somehow steal
some of the host bits. Keep in mind that in the previous example, the "125" portion of address
125.0.0.1 is fixed. If you change it to 126.0.0.1, you use a completely different Class A address, which
is not your goal. Your goal is to create more networks from the original 125.0.0.0 network.
If you understand that the default mask of 255.0.0.0 for a Class A address indicates that the first octet
is fixed and that the remaining bits can be set to any value except 255.255.255, you are well on your
way to understanding the solution to subnetting. Consider the following:
255.0.0.0
125.0.0.0
The 255 overlays the first octet. What happens if you extended the default mask by another octet?
255.255.0.0
125.0.0.0
You indicate that both the first and the second octets are now fixed (the first one because of the default
mask for a Class A address and the second one because you added a subnet mask). In this case, the
default mask is 255.0.0.0 and the subnet mask is 0.255.0.0. This combination creates a mask of
255.255.0.0. Now, a change in the second octet creates a new subnet.
125.1.0.0 with a mask of 255.255.0.0 and 125.2.0.0 with a mask of 255.255.0.0 are different subnets.
8
Consider the following:
255.255.0.0
125.1.0.0
255.255.0.0
125.2.0.0
Both addresses are now using the first two octets as a combined network portion of the address
(network and subnetwork). Both addresses still have the last two octets available as host addresses.
You can now create 253 different subnetworks of the major net 125.0.0.0. They range from 125.1.0.0
255.255.0.0 (subnet 1) to 125.254.0.0 255.255.0.0 (subnet 254). Using subnet 125.0.0.0 255.255.0.0
(subnet 0) is discouraged. It is easily confused with the major network 125.0.0.0 255.0.0.0 by routers
running routing protocols, such as RIP or IGRP, which do not store the subnet masks associated with
the networks they know.
This example of subnetting a Class B address illustrates how subnetting works. Assume that you are
assigned the Class B address 172.16 from the Network Information Center (NIC). The first things you
would to determine is how many subnets you need and how many nodes per subnet you need to define.
A typical (and the easiest to use) Class B subnet mask is eight bits. Because the third octet is the first
"free" octet for Class B, you can start there.
An eight-bit subnet mask is 255.255.255.0. This means that you have 254 subnets available and 254
addresses for nodes per subnet. In other words, your subnets range from 172.16.1.0 to 172.16.254.0.
Your host addresses on each subnet range from 172.16.X.1 to 172.16.X.254, where X is the subnet
applied. For subnet 1 (172.16.1.0), the host addresses range from 172.16.1.1 to 172.16.1.254.
A mathematical formula is used to determine the number of subnets and hosts a subnet mask allows. In
the previous example of 172.16.0.0 255.255.255.0, eight bits in the third octet are available for creating
subnets, so 28 = 256. You have to subtract 1 for subnet 0 (172.16.0.0 255.255.255.0) and another for
the broadcast address (172.16.255.0-the all 1s subnet). Remember that the all 1s address is always a
broadcast address, regardless of whether it is a subnet of all 1s, a host address of all 1s, or both.
Therefore, the formula becomes (28) - 2 = 254.
The same formula is used to determine the quantity of available host addresses. In this example, you
again have one octet-the fourth octet-available for host addresses. Therefore, (28) - 2 = 254 host
addresses are available on each subnet of 172.16.0.0.
9
Broadcasts
A broadcast is a data packet destined for all hosts on a particular physical network. Network hosts
recognize broadcasts by special addresses. Broadcasts are heavily used by some protocols, including
several important Internet protocols. Controlling broadcast messages is an essential part of the IP
network administrator's job.
The Cisco IOS software supports two kinds of broadcasting: directed and flooded. A directed
broadcast is a packet sent to a specific network or series of networks, while a flooded broadcast packet
is sent to every network. A directed broadcast address includes the network or subnet fields.
Routers provide some protection from broadcast storms by limiting their extent to the local cable.
Bridges (including intelligent bridges), because they are Layer 2 devices, forward broadcasts to all
network segments, thus propagating all broadcast storms.
The best solution to the broadcast storm is to use a single broadcast address scheme on a network.
Most modern IP implementations allow the network manager to set the address used as the broadcast
address. Many implementations, including the one in the Cisco IOS software, accept and interpret all
possible forms of broadcast addresses.
The Cisco IOS software supports IP broadcasts on both LANs and WANs. Several ways exist to
indicate an IP broadcast address. Currently, the most popular way, and the default, is an address
consisting of all ones (255.255.255.255), although the software can be configured to generate any form
of IP broadcast address. Our software also receives and understands any form of IP broadcast. To set
the IP broadcast address, use the following command in interface configuration mode:
ip broadcast-address [ip-address]
This command helps establish a different broadcast address (other than 255.255.255.255).
10
Planning Your Subnets
There are a number of things to take into account when planning subnets
1. What is the purpose of subnetting?
To create multiple, logical networks within a single Class A, B, or C network.
2. What is the function of a subnet mask?
The function of a subnet mask is to determine which portions of the IP address represent the network
and the host, respectively.
Download