This post explains briefly the network protocol IPv4 and summarizes the main aspects of it.
An IPv4 address represents a single device on an IP network.
An IPv4 address consist of 32 bits. Example: 11000110001100110110010000000000
These 32 bits are usually divided in 4 octets, and separated with a dot. Example: 11000110.00110011.01100100.00000000
In order to make them more familiar to humans, they are usually represented using decimal notation. Example: 198.51.100.0
Networks, hosts and subnet masks
The 32 binary bits are broken down into the network and host sections:
- Network number / routing prefix: identify a network (for example, University of Salamanca).
- Host identifier: identify a host inside a network (for example, Antonio’s laptop at University of Salamanca).
Subnet mask is used to identify which part of an IPv4 address belongs to a network. Subnet mask can be represented in different ways:
- In CIDR representation, a decimal number placed at the end of the IP address represents the number of bits reserved for the network. This decimal number is written after a slash (/) at the end of IPv4 address. Example: 172.18.230.127/29
- As 32-bit number, where 1 is written for each position that belongs to the network. Example: 11111111.11111111.11111111.11111000. The subnet mask is usually represented with decimal octets in the same way as an IPv4 address: 255.255.255.248. Executing AND operator on the original IPv4 address and submask gives the first value for the network.
If the submask size is not specified, then it would use a default submask. The default submask differs depending on the IPv4 Address class where they belong to. See the IPv4 Address class for further information.
The first address in a subnet is the Network Address. It means, it does not represent a host but the network itself. It may be informed along with the subnet mask. The network address is the result of applying the AND operator to the IPv4 address and the submask.
The last address in a subnet is the Broadcast Address. It means, it represents all of the hosts inside that network.
The addresses between network address and broadcast address are the host addresses.
You can calculate using some webs like this.
Ipv4 address: 172.18.230.127/29
Network address: 172.18.230.120/29
Broadcast address: 172.18.230.127
Host addresses: 172.18.230.121 – 172.18.230.126
A default gateway is a device on a TCP/IP internetwork, usually a router, which forwards IP packets to other subnets.
In most cases, you can use a Dynamic Host Configuration Protocol (DHCP) server to assign the default gateway automatically to a DHCP client. This is more straightforward than manually assigning a default gateway on each host.
IPv4 Address Classes
Internet has networks with many different sizes. Some of them contains thousands of devices, and some other just a couple of them. IPv4 offers an addressing scheme with different address classes, that represent network with different sizes, and optimize the use of addresses.
Without IPv4 Address Classes, smaller networks would cope thousands of unused host IPs. This is why different IPv4 address classes are used.
The IPv4 Address Class can be identified just by inspecting the 8 first bits in the IPv4 address:
- Class A Address: 1.x.x.x – 127.x.x.x
- Class B Address: 128.x.x.x – 191.x.x.x
- Class C Address: 192.x.x.x – 223.x.x.x
- Class D Address: 224.x.x.x – 239.x.x.x
- Class E Address: 240.x.x.x – 255.x.x.x
The Internet Assigned Numbers Authority (IANA) assigns some addresses ranges to public networks and some other to private.
Address ranges to be use by private networks are:
- Class A: 10.0.0.0 – 10.255.255.255
- Class B: 172.16.0.0 – 172.31.255.255
- Class C: 192.168.0.0 – 192.168.255.255
An IP address within private ranges is therefore considered non-routable from any external networks, as it is not unique. Any private network that needs to use IP addresses internally can use any address within these ranges without any coordination with IANA or an Internet registry. Addresses within this private address space are only unique within a given private network.
All addresses outside private ranges are considered public.
Class A Address
Default subnet mask: 255.0.0.0
Private network address range: 10.0.0.0 – 10.255.255.255
Class B Address
Default subnet mask: 255.255.0.0
Private network address range: 172.16.0.0 – 172.31.255.255
Class C Address
Default subnet mask: 255.255.255.0
Address range: 192.x.x.x – 223.x.x.x
Private network address range: 192.168.0.0 – 192.168.255.255
Class D Address
This class is reserved for multicast.
Not equipped with any submask.
Class E Address
This class is reserved for experimental purposes only for R&D or Study by the Internet Engineering Task Force IETF.
Not equipped with any submask.