IP addressing, the basics explained
Classful IPv4 addressing
TCP/IP (Transmission Control Protocol/Internet Protocol) is the networking protocol of the Internet and by extension of networks in the home and office. For TCP/IP to work, your network interfaces need to be assigned IP addresses. Note that we said network interfaces and not computers. This is because IP addresses are assigned to the network interfaces within networked devices and not to computers as a whole. This means that one computer can have more than one IP address.
For example, if you have two network interface cards on your computer, then each of them can have a different IP address, either static or dynamic.
So what is an IP address?
An IP address is a number that represents a device like a network interface card uniquely on the Internet or on a local network. For IP version 4 (IPv4), this number is actually a 32 digit (32 bit) binary number, but for convenience it's normally written as four three digit decimal numbers, each in the range from 0 to 255, representing 8 digits (bits) of the binary number and known as octets. These octets are separated by dots. For instance, a typical IPv4 IP address could look something like 192.168.001.001. Leading zeros can be omitted, and so the previous address can be shown as 192.168.1.1
The four constituent numbers together represent the network that the computer is on and the computer interface itself.
Let us first look at the network address part.
On Local Area Networks like office networks, when using Static IP addresses, the IP addresses for the devices on that network will either be allocated by yourself (if it's your network) or by the IT team administering the network. Let us assume it is our own network and we have decided this will be addressed 192.168.1.0, a Class C network.
In this instance, all of the interfaces on this network would have the same network address, as in 192.168.1. and the last number, 0, will be replaced by a number from 1 to 254 for the node address (a.k.a. device address or host address). So, in this instance, the interfaces will have addresses 192.168.1.1, 192.168.1.2, and so on up to 192.168.1.254. With a Class C network we can potentially have up to 254 devices all talking happily together.
Classes of networks and corresponding IP addresses
IPv4 Classes
Depending on the size of the network, IP-based networks can be divided into three main classes. These classes represent internationally recognised standards, and as such the numbering system presented here reflects these standards.
Class A-Class A networks can be very large networks with potentially over 16.5 million devices (255x255x254) on each network. Class A networks have their network addresses from 1.0.0.0 to 126.255.255.254, with the first octet (1-126) being the network address, and the following three octets represent the node (interface) address, for example : 10.1.1.10
Class B- Class B networks are still large networks, but are smaller than Class A networks by comparison as they can only have around 65,000 devices (255x254) on each network. Network addresses for these networks range from 128.0.0.0 to 191.255.255.254. Here the first two octets are the network address and the last two octets represent the node (interface) address, for example : 172.20.1.10
b>Class C- Class C networks are the smallest as they can only have 254 devices at the maximum. Network addresses for these range from 192.0.0.0 to 223.255.255.254. Here the first three octets are the network address and the last number only represents the node (interface) address, for example : 192.168.1.10
IP addresses from 224.0.0.0 upwards to 255.255.255.254 are reserved for Class D and Class E networks, which we will not cover here.
Network 127.0.0.0 is reserved for Loopback or Localhost duties. Address 127.0.0.1 is reserved for localhost, where the computer uses it's own loopback network interface to communicate with itself. This feature is commonly used to help develop web servers and websites offline.
IP address 255.255.255.255 should not be used as it broadcasts to all devices on the local network
For a given network address, the last available address is the broadcast address for that network. For example, for the Class C network with address 192.168.1.0, the address 192.168.1.255 is the broadcast address, used to transmit to all devices in that network. So, this address (255) along with the network address itself (0) should not be used as a node address.
Now you have got the basics on IP addresses, you'll need to know a little about a closely related topic, Subnet Masks.
Introducing Subnet Masks
In an IP network, every node (interface) on the same physical network sees all of the data packets sent out on that network. As the number of nodes on a network grows, network traffic will grow many fold, bringing down performance drastically. In such a situation, you should divide your network into different subnetworks (subnets) and minimise the traffic across the different subnetworks. If required, interconnectivity between the different subnetworks would be provided by routers, which will only transmit data meant for another subnetwork across itself. The subnet mask is used to decide which parts of an IP address belong to the network and which belong to the node. To divide a given network address into two or more subnets, you can use subnet masks.
The default subnet mask for Class A networks is 255.0.0.0, for Class B is 255.255.0.0, and for Class C is 255.255.255.0, which signify a network without subnets. The ‘255’ octets signify the network address allocation, and the ‘0’ octets signify the node address allocation. These are the most commonly used subnet masks.
Which class of network to use? Which IP address?
If your network is going to be connected to the internet in any way, there is a standard to take note of with the addressing system that you use. The internet administrator - InterNIC has, via “RFC 1597 Address Allocation for Private Internets”, allocated particular blocks of network addresses for use with Local Area Networks. These IP addresses don't conflict with those of existing internet hosts and will not be allocated for use on the Internet.
The network address blocks are:
Class A: 10.0.0.0
Class B: From 172.16.0.0 to 172.31.0.0
Class C: From 192.168.0.0 to 192.168.255.0
Computers on networks using the above IP address ranges with the correct subnet masks will be treated as private ones, so you would ideally use addresses from these reserved groups only.
So which IP address class should you use for your network? The answer depends on the number of devices that are going to be connected to your network, and how they should interact. You may have several servers and workstations on the network, as well as site security devices like CCTV cameras. They may run fine together, or you may want to assign these to separate networks to split the data streams. Alternatively you could use VLANs to manage the data streams, or you could use subnet masks to manage the nodes in their own sub networks.
Subnet Masks
The subnet mask is used by the TCP/IP protocol to determine whether a device is on the local subnet or on a remote network.
In TCP/IP, the parts of the IP address that are used as the network and node addresses are not fixed, so the network and node addresses above cannot be determined unless you have more information. This information is supplied in another 32-bit binary number called a subnet mask.
In this example, the subnet mask is 255.255.255.0. It is not obvious what this number means unless you know that 255 in binary notation equals 11111111; so, the subnet mask 255.255.255.0 shown in binary, is:
11111111.11111111.11111111.0000000
Lining up the IP address and the subnet mask together, the network and node portions of the address can be separated:
11000000.10101000.01111011.10000100 - node IP address (192.168.123.132)
11111111.11111111.11111111.00000000 - Subnet mask (255.255.255.0)
The first 24 bits (the number of ones in the subnet mask) are identified as the network address, with the last 8 bits (the number of remaining zeros in the subnet mask) identified as the node address. This gives you the following:
11000000.10101000.01111011.00000000 -- Network address (192.168.123.0)
00000000.00000000.00000000.10000100 -- node address (000.000.000.132)
So now you can see, for this example using a 255.255.255.0 subnet mask, that the network address is 192.168.123.0, and the node address is 0.0.0.132. When a data packet arrives on the 192.168.123.0 subnet (from the local subnet or a remote network), and it has a destination address of 192.168.123.132, that device will receive it from the network and process it.
Almost all decimal subnet masks convert to binary numbers that are all ones on the left and all zeros on the right. Some common subnet masks are:
Decimal Binary 255.000.000.000 1111111.00000000.00000000.00000000 255.255.000.000 1111111.11111111.00000000.00000000 255.255.255.000 1111111.11111111.1111111.00000000 255.255.255.192 1111111.11111111.1111111.11000000 255.255.255.224 1111111.11111111.1111111.11100000
Internet RFC 1878 (available from http://www.internic.net) describes the valid subnets and subnet masks that can be used on TCP/IP networks.
Subnetting
As we have mentioned earlier, Class A, B, or C TCP/IP networks can be further divided, or split into subnets, by a network administrator. A network administrator who is allocating a block of IP addresses may be administering networks that are not organized in a way that easily fits these addresses. For example, you have a network with 150 nodes which you wish to divide into three networks. Each of these three networks has 50 nodes. You allocate the Class C network 192.168.123.0. This means that you could use the IP addresses 192.168.123.1 to 192.168.123.254.
With the default subnet mask applied you would be able to give IP addresses for up to 254 nodes. This works fine if all 150 nodes are on a single network. However in this case your 150 nodes are to be on three separate networks. Instead of requesting more address blocks for each network, you divide your network into subnets that enable you to use one block of addresses.
In this case, you divide your network into four subnets by using a subnet mask that makes the network address larger and the possible range of node addresses smaller. In other words, you are 'borrowing' some of the bits usually used for the device address, and are using them for the network portion of the address.
Using the subnet mask 255.255.255.192 would give you four networks of 62 nodes each. This works because in binary notation, 255.255.255.192 is the same as 1111111.11111111.1111111.11000000. The first two digits of the last octet become network addresses, so you get the additional subnetworks 00000000 (0), 01000000 (64), 10000000 (128) and 11000000 (192). In these four subnetworks, the last 6 binary digits can be used for node addresses.
Some administrators may only use two of the subnetworks when using 255.255.255.192 as a subnet mask. For more information on this topic, search the internet for RFC 1878.
Using a subnet mask of 255.255.255.192, your 192.168.123.0 network then becomes the four subnetworks:
192.168.123.0
192.168.123.64
192.168.123.128
192.168.123.192
These four subnetworks would have as valid node address ranges:
192.168.123.1-62
192.168.123.65-126
192.168.123.129-190
192.168.123.193-254
Remember, again, that binary node addresses with all ones or all zeros are invalid, so you cannot use addresses with the last octet value of 0, 63, 64, 127, 128, 191, 192, or 255.
You can see how subnetting works by looking at two node addresses, 192.168.123.71 and 192.168.123.133. If you used the default Class C subnet mask of 255.255.255.0, both addresses are on the 192.168.123.0 network. However, if you use the subnet mask of 255.255.255.192, they are on different subnetworks; 192.168.123.71 is on the 192.168.123.64 subnetwork, 192.168.123.133 is on the 192.168.123.128 subnetwork.
Default Gateways
If a TCP/IP node needs to communicate with a node on another network or subnetwork, it will usually communicate through a router. In TCP/IP terms, a router that is specified on a node, which links the node's subnet to other networks, is called a default gateway.
The following explains how TCP/IP informs a node to determine whether or not to send data packets to its default gateway to reach another node on the network.
When a node attempts to communicate with another node using TCP/IP, it performs a comparison process using the defined subnet mask and the destination IP address versus the subnet mask and its own IP address. The result of this comparison tells the node whether the destination is a local node or a remote node.
If the result of this process determines the destination to be a local node, then it will simply send the data packet on the local subnet. If the result of the comparison determines the destination to be a remote node, then it will forward the data packet to the default gateway address defined in its TCP/IP properties. It is then the responsibility of the router to forward the data packet to the correct subnet.
Troubleshooting
TCP/IP network problems are often caused by incorrect configuration of the three main entries in a node's TCP/IP properties. By understanding how errors in TCP/IP configuration affect network operations, you can solve many common TCP/IP problems.
Incorrect Subnet Mask: If a network uses a subnet mask other than the default mask for its address class, and a node is still configured with the default subnet mask for the address class, communication will fail to some nearby networks but not to distant ones. As an example, if you create four subnets (such as in the previous subnetting example) but use the subnet mask of 255.255.255.0 in your TCP/IP configuration, nodes will not be able to determine that some nodes are on different subnets than their own. When this happens, packets destined for devices on different physical networks that are part of the same Class C address will not be sent to a default gateway for delivery. A common symptom of this is when a node can communicate with nodes that are on its local network and can talk to all remote networks except those that are nearby and have the same class A, B, or C address. To fix this problem, just enter the correct subnet mask in the TCP/IP configuration for that node.
Incorrect IP Address: If you put nodes with IP addresses that should be on separate subnets on a local network with each other, they will not be able to communicate. They will try to send packets to each other through a router that will not be able to forward them correctly. A symptom of this problem is a node that can talk to devices on remote networks, but cannot communicate with some or all computers on their local network. To correct this problem, make sure all computers on the same physical network have IP addresses on the same IP subnet (if this is what is required).
Incorrect Default Gateway: A node configured with an incorrect default gateway will be able to communicate with nodes on its own network segment, but will fail to communicate with nodes on some or all remote networks. If a single physical network has more than one router, and the wrong router is configured as a default gateway, a node will be able to communicate with some remote networks, but not others. This problem is common if an organization has a router to an internal TCP/IP network and another router connected to the Internet.
Static IP addresses versus Dynamic IP addresses
In assigning IP addresses to nodes, you have two choices. You can either go around typing in the individual address on each node (static IP addressing) or you can set up one node to assign IP addresses to the others (dynamic IP addressing). For typical IP CCTV and IP access control networks, Static IP addressing is the preferred route, since a loss of power event on a unit does not cause it's IP address to change. Dynamic addressing is sometimes used on “plug and play” IP CCTV systems, but these systems usually incorporate software to keep track of a device using Its physical (MAC) address.
In a computing environment, dynamic IP (DHCP) addressing may be preferred for three reasons. First, it makes the job of administering the network such as adding new devices, avoiding IP clashes, etc a lot easier. And second, since only those machines that are switched on will need an IP address, you could potentially have more machines on your network with dynamic addressing than you could with static addressing. Finally, mobile computing has become an everyday reality, and notebook computers have a likelihood of moving from one network to another or from one subnet to another. In such a situation, if you have static IP addressing, you have to reconfigure the machine every time you move it - something that is eminently avoidable. So the benefits to these types of networks are obvious.
Dynamic addressing uses DHCP (Dynamic Host Configuration Protocol) to allocate nodes with addresses automatically. To make DHCP work on your network you have to set up a DHCP server.
The good news is that network admins can have both addressing systems running on their network together, as long as they reserve the static IP address ranges on the DHCP server.