The IP Address:
The IP address is a software address specific to TCP/IP. Each device on the network has a unique address, even if the network is as large as the global Internet. In the previous example, the ifconfig command assigns the IP address 172.16.5.4 to the Ethernet interface eth0. You must define an IP address for every interface, either manually or through the use of a DHCP server, because the TCP/IP network is independent of the underlying hardware, which means that the IP address cannot be derived from the network hardware.
This approach has advantages and disadvantages, and is different from the address approach used by some other networks. NetBIOS uses the Ethernet hardware address as its address, and NetWare IPX incorporates the Ethernet address into the NetWare address. Using the address that is available in the hardware makes these systems simple to configure because the system administrator does not need to be concerned with or knowledgeable about network addresses. But these systems are dependent on the underlying Ethernet, making it difficult or impossible to run them over global networks. TCP/IP is more difficult to configure, but it has the power to run a global network.
The netmask Argument The IP address includes a network portion that is used to route the packet through the Internet and a host portion that is used to deliver the packet to a computer when it reaches the destination network. The netmask argument identifies which bits in the IP address represent the network, and which bits represent the host. If no netmask (network mask) is defined, the address is divided according to the old address class rules. In effect, these rules say the following:
- If the first byte is less than 128, use the first eight bits for the network and the next 24 bits for the host.
- If the value of the first byte is from 128 to 191, use the first 16 bits for the network and the last 16 bits for the host.
- If the value of the first byte is from 192 to 223, use the first 24 bits for the network and the last eight bits for the host.
- Addresses with a first byte that is greater than 223 are not assigned to network hardware interfaces.
The old address classes did not provide enough flexibility for defining addresses. Three address classes proved inadequate to handle the huge number of addresses in the Internet and the incredible diversity of needs of the different networks connecting to the Internet. The solution is classless IP addresses. Classless addressing treats an IP address as 32 bits that can be divided between network and host portions in any way. The division of bits is controlled by a bit mask. If a bit is "on" in the mask (the bit is a one), the corresponding bit in the address is a network bit. If the bit is "off" (the bit is a zero), the corresponding bit in the address is a host bit. Here is our sample ifconfig command again:
ifconfig eth0 172.16.5.4 netmask 255.255.255.0 broadcast 172.16.5.255
By the old class rules, the address 172.16.5.4 would define host 5.4 on network 172.16. The netmask argument 255.255.255.0 says that the first 24 bits of the address are the network portion, and that only the last eight bits are used to define the host. With this mask, the address is interpreted as host 4 on network 172.16.5.