| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| IP Address TutorialMost people know that all of the computers connected to a network have IP addresses. But people who are new to the field or have never managed a network rarely understand how IP addresses work. This tutorial is designed to help the newcomer understand the mechanics of IP addresses.In order for computers to communicate with each other across a network, they must have some means of uniquely identifying themselves. Because different networks often have to communicate with each other, common names are not sufficient; the use of common names would require the administrators of different networks to coordinate between themselves to avoid name conflicts. Add to that the fact that that numbers can be dealt with more efficiently than variable length text and it's easy to understand why names are not a good idea. Each computer on a network, frequently referred to as a host, is assigned a unique 32-bit address that is used in all communications to and from that host. Each IP address is really a pair of identifiers where one part of the pair uniquely identifies the network and the other part of the pair uniquely identifies the host on a specific network. In order to fully understand how the pair is specified, it's helps to start thinking of an IP address in its binary form: 192.168.1.1 = 11000000.10101000.00000001.00000001
Now we can describe the pair using more accurate terminology: of the 32-bits in an IP address, some number of bits are allocated to the network ID and the remaining bits are allocated to the host ID. Network ClassThere are five classes of IP addresses:
Now we know that the network class of any IP address can be determined by looking at the first few bits of the IP address. Using the example above, it's easy to determine that the address 192.168.1.1 belongs to a Class C network: 192.168.1.1 = 11000000.10101000.00000001.00000001
We also now know that on a traditional class C network, the address 192.168.1.1 consists of a 24-bit network address and an 8-bit host address. In other words, 192.168.1.1 is the first host on the 192.168.1.0 network. 192.168.1.1 = 1100000.10101000.00000001.00000001
<-------network---------> <-host-> 0's and 1'sIn the description of the different network classes, you probably noticed that the maximum number of hosts in a network is decreased by 2. In every network, there are two special host ID's:
192.168.1.0 = 11000000.10101000.00000001.00000000 = network
192.168.1.255 = 11000000.10101000.00000001.11111111 = broadcast We can now go a little further to establish four basic principals:
Also, any IP address beginning with 127.0.0 is a loopback address and refers to the local host; e.g., on any given host, this address refers to the host itself. We can now summarize the entire address space for a network as follows:
Public vs. Private AddressesBy now, it may have occurred to you that the number of valid IP addresses is quite limited given the number of computers attached to networks worldwide. Since IP address must be unique, won't we run out? Yes and no. At the time the IP address scheme was developed, computers were expensive and no one anticipated a world where there would be more than tens of networks, each with hundreds of hosts. The resulting misconception was that the pool of addresses was endless (232). Theoretically, IP addresses must be unique; that is, they must uniquely identify a single network resource. In practice, the only addresses that must be globally unique are ones that are used to identify public Internet resources such as web servers and mail servers. When you type http://www.tldp.org in the address bar of your browser, www.tldp.org must resolve to a public IP address that belongs only to tldp.org. The IP addresses of computers that communicate amongst themselves inside a private network only need to be unique across the local network. The same block of private addresses can be reused in two different networks as long as computers on the two networks do not need to communicate directly with each other. To this end, the Network Information Center (NIC) has reserved blocks of addresses in each class for private use. Organizations are free to use these private addresses in any way they deem necessary. Computers connected to two different independent private networks will never communicate with each other using their private addresses. The manner in which they do communicate involves the use of other protocols and technologies which are outside the scope of this tutorial. The addresses reserved for internal use are:
+ Note that we reference the number of IP addresses rather than the number of hosts; the number of hosts will always be fewer by at least two (network address and broadcast address). The number of host addresses may decrease further if a network is subdivided into two or more subnets as discussed in the next section. What is a subnet?Consider a small company with two offices, one on each US coast. The IT manager in each office must be able to administer its own internal network, but all of the computers in both offices need to seamlessly communicate with each other over a WAN. One way to facilitate this split in responsibility without impeding communication is to split the larger network into two or more smaller, more manageable units call subnets. We learned earlier that one can usually determine the network ID by examining the first few bits of an IP address; we're about to find out that this is not always the case. When subnets are involved, the network ID contains more than its usual number of bits and the network is configured to use a specific number of bits as its network ID. This is accomplished by the specification of a netmask (or subnet mask). Like an IP address, a netmask is a 32-bit address that has a network part and a host part. However, the network part of a netmask consists of some number of contiguous 1-bits with the remaining host bits set to 0. To continue using our class C example where the network ID has 24 bits, the typical class C netmask can be calculated as follows: 11111111.11111111.11111111.00000000 = 255.255.255.0
By now, you're most likely asking "why do I need to know this"? Understanding IP addresses and netmasks is fundamental to troubleshooting network connectivity issues: Why does ping respond with "Destination host unreachable"? My Linux box is sharing its Internet connection, but my PC can't get to www.tldp.org -- what did I do wrong? While the subject of routers and gateways is outside the scope of this tutorial, they are necessary for communication between subnets so we need to at least understand the basics of what they're responsible for and how they depend on IP addresses and netmasks to do their job. IP RoutingThink of a router as an electronic mailman; instead of deliverying letters, it delivers computer messages known as packets. Our mailman knows how to do two things:
The street address on our packet is the destination IP address. The zip code on our message is computed by applying the netmask to the destination IP address to determine the address of the destination network. The zip code for our local network is our network address. Again, let's use our class C example:
destination address: 192.168.001.015 = 11000000.10101000.00000001.00001111
& our netmask: 255.255.255.000 = 11111111.11111111.11111111.00000000 ----------------------------------- = destination network: 11000000.10101000.00000001.00000000 local network: 192.168.001.000 = 11000000.10101000.00000001.00000000 Because the masked destination address matches the address of our local network, our router knows the packet is destined for the local network. Lets try a different example:
destination address: 192.167.001.015 = 11000000.10100111.00000001.00001111
& our netmask: 255.255.255.000 = 11111111.11111111.11111111.00000000 ----------------------------------- = destination network: 11000000.10100111.00000001.00000000 local network: 192.168.001.000 = 11000000.10101000.00000001.00000000 Since the masked destination address is different from the address of our local network, we know the packet is destined for a remote network. All of the packets between these two networks must be mediated through at least one router. The manner in which a netmask is specified is software dependent. Some network configuration tools require the entry of both the network address and subnet mask. Other tools accept the entry of a more compact notation where the network address is simply followed by a slash and the number of bits in the network address. The following specifications are equivalent: network = 192.168.1.0 netmask = 255.255.255.0
network = 192.168.1.0/24 How do I create subnets?Since it's easier to learn by example, let's assume our small two-office company has fewer than 254 hosts and that a class C network will leave them plenty of room for expansion. They decide to implement two subnets using the IP addresses reserved for private class C networks (192.168.0.0 to 192.168.255.255) and select 192.168.1/24 as the network ID for the entire network. To allow for equal growth in both offices, they decide to split the network into two subnets with an equal number of hosts. This division is accomplished by taking one bit from the host portion of the IP address and allocating it to the network portion: 11111111.11111111.11111111.10000000 = 255.255.255.128
Each additional bit added to the network portion of the address effectively splits the network or subnet in half with an equal number of hosts available on each subnet:
Look closely at what happened when we introduced the two subnets. Our original class C network has a network address, a broadcast address and 254 possible host addresses. After subnetting, there are 252 host addresses because each subnet must have its own all 0's network address and all 1's broadcast address. Two IP addresses in the original range are no longer valid for hosts. References:
FeedbackWe hope this tutorial has been useful; as with all of the content on our site, we appreciate your comments. Please use the feedback link at the bottom of the page to tell us whether this tutorial has been useful and for submitting suggestions on how we can make improvements. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||