• Tidak ada hasil yang ditemukan

IP Subnets

Dalam dokumen TCP/IP Tutorial and Technical Overview (Halaman 48-53)

Comments Welcome

Chapter 2. Internetworking and Transport Layer Protocols

2.1 Internet Protocol (IP)

2.1.2 IP Subnets

can be further subdivided: this division is controlled by the authority which owns the network, and not by the InterNIC.

2.1.1.2 Special IP Addresses

Any component of an IP address with a value all bits 0 or all bits 1 has a special meaning:

all bits 0

Stands for this: this host (IP address with <host address>=0) or this network (IP address with <network address>=0). When a host wants to communicate over a network, but does not yet know the network IP address, it may send packets with <network address>=0. Other hosts on the network will interpret the address as meaning this network. Their reply will contain the fully qualified network address, which the sender will record for future use.

all bits 1

Stands for all: 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 inside the local system and never access a physical network (loopback interfaces).

The division of the local part of the IP address into subnet number and host number parts can be chosen freely by the local administrator; any bits in the local part can be used to form the subnet. The division is done using a subnet mask which is a 32 bit number. Zero bits in the subnet mask indicate bit positions ascribed to the host number, and ones indicate bit positions ascribed to the subnet number. The bit positions in the subnet mask belonging to the network number are set to ones but are not used. Subnet masks are usually written in dotted decimal form, like IP addresses.

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 2.1.1.2, “Special IP Addresses” on page 30). For example, a subnetted Class B network, which has a 16-bit local part, could use one of the following schemes:

Ÿ The first byte is the subnet number; the second byte is the host number. This gives us 28-2 (254 with the values 0 and 255 being reserved) possible subnets, each having up to 28-2 (254) hosts. 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 us 212-2 (4094) possible subnets but only 24-2 (14) hosts per subnet. The subnet mask is 255.255.255.240.

There are many other possibilities. In fact, the number of subnets and hosts and future requirements should be taken into consideration before defining a subnet. In the above example, for a subnetted Class B network, there are 16 bits left for the subnet number and the host number fields. The administrator has the choice of defining either a larger number of subnets with a small number of hosts in each, or a smaller number of subnets with many hosts.

While the administrator is completely free to assign the subnet part of the local address in any legal fashion, 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 because 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 “good” masks, but masks such as 255.255.252.252 and 255.255.255.15 are not. (In fact, hardly any TCP/IP implementation supports non-contiguous subnet masks, and their use is commonly discouraged, especially in CIDR environments that would become non-functional by choosing

non-conventional subnet masks or network prefixes.)

2.1.2.1 Types of Subnetting

There are two types of subnetting: static and variable length. Variable length is the more flexible of the two. Which type of subnetting is available depends upon the routing protocol being used; native IP routing supports only static subnetting, as does the widely used RIP protocol. However, RIP Version 2 supports variable length subnetting as well. See 3.3.1, “Routing Information Protocol (RIP)” on page 106 for a description of RIP and RIP2. Chapter 3, “Routing Protocols” on page 95 discusses routing protocols in detail.

Static Subnetting: Static subnetting means that all subnets in the subnetted network use the same subnet mask. This is simple to implement and easy to maintain, but it implies wasted address space for small networks. For example, a network of four hosts that uses a subnet mask of 255.255.255.0 wastes 250 IP

addresses. It also makes the network more difficult to reorganize with a new subnet mask. All hosts and routers are required to support static subnetting.

Variable Length Subnetting: When variable length subnetting is used, the subnets that make up the network can use different subnet masks. A small subnet with only a few hosts needs a subnet mask that accommodates only these few hosts. A subnet with many hosts attached may need a different subnet mask to accommodate the large number of hosts. The possibility to assign subnet masks according to the needs of the individual subnets will help conserve network addresses. Also, a subnet can be split into two parts by adding another bit to the subnet mask. Other subnets in the network are unaffected by the change.

Variable length subnetting allows you to divide the network so that it is possible to define adequate hosts for each subnet by changing the subnet mask for each network. This can be achieved by configuring the routers accordingly. Please note that not every host and router supports variable length subnetting. With static subnetting each subnet has the same number of hosts. If it is required to have different numbers of hosts for each network, then variable length subnetting should be used.

Only networks of the size needed will be allocated and routing problems will be solved by isolating networks with routers that support variable subnetting. A host that does not support this kind of subnetting would have to route to a router that supports variable subnetting.

Mixing Static and Variable Length Subnetting: At first sight, it appears that the presence of a host that only supports static subnetting would prevent variable length subnetting from being used anywhere in the network. Fortunately this is not the case. Provided that the routers between subnets with different subnet masks are using variable length subnetting, the routing protocols employed are able to hide the difference between subnet masks from the hosts in a subnet. Hosts can continue to use basic IP routing and offload all of the complexities of the subnetting to dedicated routers.

2.1.2.2 A Static Subnetting Example

Recall that an IP address consists of the pair <network address><host address>.

For example, let us take a class A network; the address format is shown in Figure 8:

Class A 0 netID hostID

1 2 3 01 8 6 4 1

Figure 8. IP - Class A Address without Subnets Let us use the following IP address:

ðððð1ðð1 ð1ðððð11 ðð1ðð11ð ððððððð1 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>

Subnets are an extension to this by considering a part of the <host address> to be a subnetwork address. IP addresses are then interpreted as <network

address><subnetwork address><host address>.

For example, you may wish to choose the bits from 8 to 25 of a class A IP address to indicate the subnet addresses, and the bits from 26 to 31 to indicate the actual host addresses. Figure 9 shows the subnetted address that has thus been 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 9. IP - Class A Address with Subnet Mask and Subnet Address

We normally use a bit mask, known as the subnet mask, to identify which bits of the original host address field should indicate the subnet number. In the above example, the subnet mask is 255.255.255.192 in decimal notation (or 11111111 11111111 11111111 11000000 in bit notation). Note that, by convention, the

<network address> is masked as well.

For each of these subnet values, only 218-2 addresses (from 1 to 262143) are valid because of the all bits 0 and all bits 1 number restrictions. This split will therefore give 262142 subnets each with a maximum of 26-2 or 62 hosts.

You will notice that the value applied to the subnet number takes the value of the full byte with non-significant bits being set to zero. For example, the hexadecimal value 01 in this subnet mask assumes an 8-bit value 01000000 and gives a subnet value of 64 and not 1 as it might seem.

Applying this mask to our sample class A address 9.67.38.1 would break the address down as follows:

ðððð1ðð1 ð1ðððð11 ðð1ðð11ð ððððððð1 = 9.67.38.1 (class A address) 11111111 11111111 11111111 11--- 255.255.255.192 (subnet mask)

===================================== logical_AND

ðððð1ðð1 ð1ðððð11 ðð1ðð11ð ðð--- = 9.67.38 (subnet base address)

This leaves a host address of:

--- --- --- --ððððð1 = 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 (see 2.1.3, “IP Routing”

on page 35).

Note that the actual subnet number would be:

--- ð1ðððð11 ðð1ðð11ð ðð--- = 6876ð (subnet number)

You will notice that the subnet number shown above 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) and has no meaning in terms of IP routing.

The division of the original <host address> part into <subnet> and <host> parts can be chosen freely by the local administrator, except that the values of all zeroes and all ones in the <subnet> field are reserved for special addresses.

Note: Because the range of available IP addresses is decreasing rapidly, many routers do support the use of all zeroes and all ones in the <subnet> field, though this is not coherent with the standards.

2.1.2.3 A Variable Length Subnetting Example

Consider a corporation that was assigned a Class C network 165.214.32.0, and it has the requirement to split this address range into five separate networks. The required number of hosts for each subnet are following:

Ÿ 1. Subnet: 50 hosts

Ÿ 2. Subnet: 50 hosts

Ÿ 3. Subnet: 50 hosts

Ÿ 4. Subnet: 30 hosts

Ÿ 5. Subnet: 30 hosts

This cannot be achieved by using static subnetting. For this case, the static

subnetting can only divide the network into four subnets with 64 hosts each or eight subnet with 32 hosts each. This method would not meet the requirement.

To be able to divide the network into five subnets, multiple masks should be defined. Using a mask of 255.255.255.192, the network will be divided into four subnets with 64 hosts each. After that, the last subnet can be further divided into two subnets with 32 hosts each by using a mask of 255.255.255.224. There will be three subnets with 64 hosts each and two subnets with 32 hosts each. This would meet the requirements.

2.1.2.4 Obtaining a Subnet Mask

Usually, hosts will store the subnet mask to be used in a configuration file.

However, sometimes this cannot be done, as for example in the case of a diskless workstation. The ICMP protocol includes two messages, address mask request and address mask reply, that allow hosts to obtain the correct subnet mask from a server. See 2.2.1.10, “Address Mask Request (17) and Address Mask Reply (18)”

on page 65 for more information.

2.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. All routers are multi-homed since their purpose is to join networks or subnets. A multi-homed host always has different IP addresses associated with each network adapter, since each adapter is in a different subnet or network.

Dalam dokumen TCP/IP Tutorial and Technical Overview (Halaman 48-53)