• Tidak ada hasil yang ditemukan

IP subnets

Dalam dokumen TCP/IP Tutorial and Technical Overview (Halaman 93-98)

TCP/IP

Chapter 3. Internetworking protocols

3.1 Internet Protocol (IP)

3.1.2 IP subnets

Chapter 3. Internetworking protocols 69 meaning this network. Their replies contain the fully qualified network address, which the sender records for future use.

• All bits 1: An address with all bits one is interpreted as all networks or all hosts. For example, the following means all hosts on network 128.2 (class B address):

128.2.255.255

This is called a directed broadcast address because it contains both a valid <network address> and a broadcast <host address>.

• Loopback: The class A network 127.0.0.0 is defined as the loopback network. Addresses from that network are assigned to interfaces that process data within the local system. These loopback interfaces do not access a physical network.

The division of the local part of the IP address into a subnet number and host number is chosen by the local administrator. Any bits in the local portion can be used to form the subnet. The division is done using a 32-bit subnet mask.

Bits with a value of zero bits in the subnet mask indicate positions ascribed to the host number. Bits with a value of one indicate positions ascribed to the subnet number. The bit positions in the subnet mask belonging to the original network number are set to ones but are not used (in some platform

configurations, this value was actually specified with zeros instead of ones, but either way it is not used). Like IP addresses, subnet masks are usually written in dotted decimal form.

The special treatment of all bits zero and all bits one applies to each of the three parts of a subnetted IP address just as it does to both parts of an IP address that has not been subnetted (see 3.1.1.3, “Reserved IP addresses”

on page 68). For example, subnetting a Class B network could use one of the following schemes:

• The first octet is the subnet number; the second octet is the host number.

This gives 28-2 (254) possible subnets, each having up to 28-2 (254) hosts. Recall that we subtract two from the possibilities to account for the all ones and all zeros cases. The subnet mask is 255.255.255.0.

• The first 12 bits are used for the subnet number and the last four for the host number. This gives 212-2 (4094) possible subnets but only 24-2 (14) hosts per subnet. The subnet mask is 255.255.255.240.

In this example, there are several other possibilities for assigning the subnet and host portions of the address. The number of subnets and hosts and any future requirements should be considered before defining this structure. In the last example, the subnetted Class B network has 16 bits to be divided between the subnet number and the host number fields. The network administrator defines either a larger number of subnets each with a small number of hosts, or a smaller number of subnets each with many hosts.

When assigning the subnet part of the local address, the objective is to assign a number of bits to the subnet number and the remainder to the local address. Therefore, it is normal to use a contiguous block of bits at the beginning of the local address part for the subnet number. This makes the addresses more readable. (This is particularly true when the subnet occupies 8 or 16 bits.) With this approach, either of the subnet masks above are

"acceptable" masks. Masks such as 255.255.252.252 and 255.255.255.15 are “unacceptable.” In fact, most TCP/IP implementations do not support non-contiguous subnet masks. Their use is universally discouraged.

Chapter 3. Internetworking protocols 71 3.1.2.1 Types of subnetting

There are two types of subnetting: static and variable length. Variable length subnetting is more flexible than static. Native IP routing and RIP Version 1 support only static subnetting. However, RIP Version 2 supports variable length subnetting (refer to Chapter 4, “Routing protocols” on page 137).

Static subnetting

Static subnetting implies that all subnets obtained from the same network use the same subnet mask. While this is simple to implement and easy to maintain, it may waste address space in small networks. Consider a network of four hosts using a subnet mask of 255.255.255.0. This allocation wastes 250 IP addresses. All hosts and routers are required to support static subnetting.

Variable length subnetting

When variable length subnetting is used, allocated subnets within the same network can use different subnet masks. A small subnet with only a few hosts can use a mask that accommodates this need. A subnet with many hosts requires a different subnet mask. The ability to assign subnet masks according to the needs of the individual subnets helps conserve network addresses. Variable length subnetting divides the network so that each subnet contains sufficient addresses to support the required number of hosts.

An existing subnet can be split into two parts by adding another bit to the subnet portion of the subnet mask. Other subnets in the network are unaffected by the change.

Mixing static and variable length subnetting

Not every IP device includes support for variable length subnetting. Initially, it would appear that the presence of a host that only supports static subnetting prevents the use of variable length subnetting. This is not the case. Routers interconnecting the subnets are used to hide the different masks from hosts.

Hosts continue to use basic IP routing. This offloads subnetting complexities to dedicated routers.

3.1.2.2 Static subnetting example

Consider the class A network shown in Figure 17.

Class A 0 netID hostID

1 2 3 01 8 6 4 1

Figure 17. IP - Class A address without subnets

Using the following IP address:

00001001 01000011 00100110 00000001 a 32-bit address

9 67 38 1 decimal notation (9.67.38.1)

9.67.38.1 is an IP address (class A) having

9 as the <network address>

67.38.1 as the <host address>

The network administrator may wish to choose the bits from 8 to 25 to indicate the subnet address. In that case, the bits from 26 to 31 indicate the actual host addresses. Figure 18 shows the subnetted address derived from the original class A address.

1 2 3 01 8 6 4 1 Class A

Subnet 0 subnet number host

netID ID

Figure 18. IP - Class A address with subnet mask and subnet address

A bit mask, known as the subnet mask, is used to identify which bits of the original host address field indicate the subnet number. In the above example, the subnet mask is 255.255.255.192 (or 11111111 11111111 11111111 11000000 in bit notation). Note that, by convention, the <network address> is included in the mask as well.

Because of the all bits 0 and all bits 1 restrictions, this defines 218-2 (from 1 to 262143) valid subnets. This split provides 262142 subnets each with a maximum of 26-2 (62) hosts.

The value applied to the subnet number takes the value of the full octet with non-significant bits set to zero. For example, the hexadecimal value 01 in this

Chapter 3. Internetworking protocols 73 subnet mask assumes an 8-bit value 01000000. This provides a subnet value of 64.

Applying the 255.255.255.192 to the sample class A address 9.67.38.1 provides the following information:

00001001 01000011 00100110 00000001 = 9.67.38.1 (class A address) 11111111 11111111 11111111 11--- 255.255.255.192 (subnet mask) ===================================== logical_AND

00001001 01000011 00100110 00--- = 9.67.38.0(subnet base address)

This leaves a host address of:

--- --- --- --000001 = 1 (host address) IP will recognize all host addresses as being on the local network for which the logical_AND operation described above produces the same result. This is important for routing IP datagrams in subnet environments (refer to 3.1.3, “IP routing” on page 74).

The actual subnet number is:

--- 01000011 00100110 00--- = 68760 (subnet number) This subnet number is a relative number. That is, it is the 68760th subnet of network 9 with the given subnet mask. This number bears no resemblance to the actual IP address that this host has been assigned (9.67.38.1). It has no meaning in terms of IP routing.

The division of the original <host address> into <subnet><host> is chosen by the network administrator. The values of all zeroes and all ones in the

<subnet> field are reserved.

Because the range of available IP addresses is decreasing rapidly, many routers now support the use of all zeroes and all ones in the <subnet> field.

This is not consistent with the defined standards.

Note:

3.1.2.3 Variable length subnetting example

Consider a corporation that has been assigned the Class C network

165.214.32.0. The corporation has the requirement to split this address range into five separate networks each with the following number of hosts:

• Subnet #1: 50 hosts

• Subnet #2: 50 hosts • Subnet #3: 50 hosts • Subnet #4: 30 hosts • Subnet #5: 30 hosts

This cannot be achieved with static subnetting. For this example, static subnetting divides the network into four subnets each with 64 hosts or eight subnets each with 32 hosts. This subnet allocation does not meet the stated requirements.

To divide the network into five subnets, multiple masks should be defined.

Using a mask of 255.255.255.192, the network can be divided into four subnets each with 64 hosts. The fourth subnet can be further divided into two subnets each with 32 hosts by using a mask of 255.255.255.224. There will be three subnets each with 64 hosts and two subnets each with 32 hosts.

This satisfies the stated requirements.

3.1.2.4 Determining the subnet mask

Usually, hosts will store the subnet mask in a configuration file. However, sometimes this cannot be done, for example, as in the case of a diskless workstation. The ICMP protocol includes two messages: address mask request and address mask reply. These allow hosts to obtain the correct subnet mask from a server (refer to 3.2.1.10, “Address Mask Request (17) and Address Mask Reply (18)” on page 111).

3.1.2.5 Addressing routers and multi-homed hosts

Whenever a host has a physical connection to multiple networks or subnets, it is described as being multi-homed. By default, all routers are multi-homed since their purpose is to join networks or subnets. A multi-homed host has different IP addresses associated with each network adapter. Each adapter connects to a different subnet or network.

Dalam dokumen TCP/IP Tutorial and Technical Overview (Halaman 93-98)