Internet Protocol (IP) Addressing and Subnet Mask

 < Day Day Up > 

The IP address is either a Class A, B, or C address (There are also Class D and E addresses, but they are not relevant to our discussion.) A Class A network supports many more nodes per network than either a Class B or C network. IP addresses consist of four fields. The purpose of breaking down the IP address into four fields is to define a node (or host) address and a network address. Figure 7-3 summarizes the relationships between the classes and addresses.

Figure 7-3. Classes and Addresses

Address Class

Networks

Nodes per Network

Bits Defining Network

Bits Defining Nodes per Network

A

Few

Most

8 bits

24 bits

B

Many

Many

16 bits

16 bits

C

Most

Few

24 bits

8 bits

Reserved

-

-

-

-


These bit patterns are significant in that the number of bits defines the ranges of networks and nodes in each class. For example, a Class A address uses 8 bits to define networks, and a Class C address uses 24 bits to define networks. A Class A address therefore supports fewer networks than a class C address. A Class A address, however, supports many more nodes per network than a Class C address. Taking these relationships one step further, you can now view the specific parameters associated with these address classes in Figure 7-4.

Figure 7-4. Address Classes


These addresses are used in various setup files that are covered later when the /etc/hosts file is described. Every interface on your network must have a unique IP address. Systems that have two network interfaces must have two unique IP addresses.

Subnet Mask

Your Linux system uses the subnet mask to determine whether an IP datagram is for a host on its own subnet, a host on a different subnet but the same network, or a host on a different network. Using subnets, you can have some hosts on one subnet and other hosts on a different subnet. The subnets can be separated by routers or other networking electronics that connect the subnets.

To perform routing, the only aspects of an address that your router uses are the net and subnet. The subnet mask is used to mask the host part of the address. Because you can set up network addresses in such a way that you are the only one who knows which part of the address is the host, subnet, and network, you use the subnet mask to make your system aware of the bits of your IP address that are for the host and which are for the subnet.

In its simplest form, what you are really doing with subnet masking is specifying which portion of your IP address defines the host, and which part defines the network. One of the most confusing aspects of working with subnet masks is that most books show the subnet masks in Figure 7-5 as the most common.

Figure 7-5. Subnet Masks

Address Class

Decimal

Hex

A

255.0.0.0

0xff000000

B

255.255.0.0

0xffff0000

C

255.255.255.0

0xffffff00


This way of thinking, however, assumes that you are devoting as many bits as possible to the network and as many bits as possible to the host, and that no subnets are used. Figure 7-6 shows an example of using subnetting with a Class B address.

Figure 7-6. Class B IP Address and Subnet Mask Example

Address Class

Class B

Host IP address

152.128.

12.

1

Breakdown

Network

Subnet

Hostid

Number of bits

16 bits

8 bits

8 bits

Subnet mask in decimal

255.255.

255.

0

Subnet mask in hexadecimal

0xffffff00

Example of different host on same subnet

152.128.

12.

2

Example of host on different subnet

152.128.

13.

1


In Figure 7-6, the first two bytes of the subnet mask (255.255) define the network, the third byte (255) defines the subnet, and the fourth byte (0) is devoted to the host ID. Although this subnet mask for a Class B address did not appear in the earlier default subnet mask example, the subnet mask of 255.255.255.0 is widely used in Class B networks to support subnetting.

How does your Linux system perform the comparison using the subnet mask of 255.255.255.0 to determine that 152.128.12.1 and 152.128.13.1 are on different subnets? Figure 7-7 shows this comparison.

Figure 7-7. Example of Using Subnet Mask to Compare Addresses


Figure 7-8 shows these two systems on the different subnets. You don't have to use the 8-bit boundaries to delineate the network, subnet, and host ID fields. If, for example, you want to use part of the subnet field for the host ID, you can do so. A good reason for this approach would be to accommodate future expandability. You might want subnets 12, 13, 14, and 15 to be part of the same subnet today and make these into separate subnets in the future. Figure 7-9 shows this setup.

Figure 7-8. Class B Systems on Different Subnets


Figure 7-9. Future Expandability Using Subnet Mask


These systems are connected to the same subnet, even though part of the third byte, normally associated with the subnet, is used for the host ID. In the future, the subnet mask could be changed to 255.255.252.0 and have four separate subnets of 12, 13, 14, and 15. This arrangement would require putting routers in place to route to these separate subnets.

     < Day Day Up > 


    Linux on HP Integrity Servers. A System Administrator's Guide
    Linux on HP Integrity Servers: A System Administrators Guide
    ISBN: 0131400002
    EAN: 2147483647
    Year: 2004
    Pages: 100

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net