Classful Addressing was used mainly before 1995. Today Classless Addressing is used.
An IP Address has two parts: Network Portion is like the zip code of a city, it identifies a group of devices. Host Portion is like the house number of a building, it identifies the exact owner/device.
The Subnet Mask 255.255.255.0 is used to identify which part of the IP address the Network Potion is and which the Host Portion is. It is called Mask because it “masks” the IP address with consecutive parts of ones and another consecutive part of zeros. In the example above there are 24 ones which are defining the Network Potion. A notation to specify the Subnet Mask of an IP Address that is easier to write and say is called CIDR Notation (Classless Inter-Domain Routing). The example above in CIDR notation is
203.0.113.10/24 (24, because that’s the number of ones which are defining the Network Portion). CIDR Notation is mandatory in IPv6.
Classful Adressing did not have the concept of Subnet masking. Instead IP ranges were put into classes which were given a fixed definition of what part is Network Portion and what part is Host Portion.
Class A, B and C IP ranges are Unicast (sending from one to one), that includes everything on the public internet. Class D is Multicast (sending from one to many) and that is not part of the public internet, but it can be used in companies. Class E is not used/experimental.
Out of those, the following IP addresses cannot be used on the internet (not routable), because they are reserved for internal private use (home/business network):
And here again in CIDR notation:
APIPA is another private IP range which stands for Automatic Private IP Addressing. Windows uses this to try to help out non-technical users to automatically configure IP addresses on their network, but in reality this does not often work and should be avoided.
A special address is 127.0.0.1 with the default DNS name localhost and referred to as Loopback Address. It can be used locally on your device to test if the TCP/IP stack is working correctly on your operating system and you can use http://127.0.0.1 or http://localhost if you have a web server running locally on your device for example.
- Network Address identifies a group of devices (like a zip code). We need to know Subnet mask and IP address. To classify as a Network Address, the Host Portion must be
- Broadcast Address is an identifier for all devices on a network (everybody in a zip code). To classify as a Broadcast Address, the Host Portion must be
- Host Address identifies a unique device on a network. To classify as a Host Address, the Host Portion must not be
00000000but anything in between.
To correctly classify an IP Address Type you usually need to convert the IP to binary. As an example, the following is a Network Address, because of the 00000 in the Host Portion:
The following is a Host Address, because there is a 1 in the Host Portion:
In Windows you list network details with
ipconfig /all, in Linux depending on the version either
If two devices are on the same network, they can usually communicate with each other. If they are on different networks, they need a device in between to communicate, such as a router (aka Gateway or Default Gateway).
If you ping a device on the same network as your device, e.g.
ping 192.168.0.1, you get something like
Reply from 192.168.0.1: bytes=32 time=10ms TTL=64.
If you ping a non-existing device, but still within your Network Address, e.g. ping 192.168.0.47 you get
Request timed out.
If you try to ping a device on another network and you do not have a Gateway configured, then you might get
PING: transmit failed. General failure.
Sometimes it is not easy to spot if two IP addresses are on the same network, just by looking at their Subnet Masks alone. In the following example all three IP addresses have the same subnet.
Here is how you calculate the number of available IP addresses that can be assigned to hosts on the network:
- Count the zeros in the Subnet Mask. In this case 10.
- Calculate 210 = 1024
- Take away 2 IP addresses for Network Address and Broadcast and you end up with 1022 usable addresses for hosts
- Count the zeros in the Subnet Mask. In this case 9.
- Calculate 29 = 512
- Take away 2 IP addresses for Network Address and Broadcast and you end up with 510 usable addresses for hosts
You can use calculator.net to calculate IP ranges for networks.
IPv4 are 32 bits long or 4 octets, for example
IPv6 are 128 bits long or 8 hextets, for example
2001:0DB8:4328:008D:0000:0000:00C2:52F5. To make it more readable you short leading zeros, so it looks like
2001:DB8:4328:8D:0:0:C2:52F5. You can shorten it even further by replacing all consecutive :0 and replace them with a double colon: In the example we take
:0:0 and replace it with
:: so it looks like
2001:DB8:4328:8D::C2:52F5. There can only be one double colon in the whole address though.
An IPv6 address also has two portions: Network and Interface Identifier. They are usually each 64 bits.
IPv6 allows 264 host IP addresses per network. That is 18.446.744.073.709.551.616 IP addresses within 1 network or approximately 2 addresses for every grain of sand on Earth. And that is just for 1 network. So, how many networks can there be? Also 264.
There is no concept of private addresses in IPv6 anymore. In a Dual Stack IPv4 and IPv6 can run alongside. Every IPv6 interface that needs to talk on a routed network requires at least 2 IPv6 addresses, one of them being a Unicast addresses facing the public and another one being a unique “Link-local IPv6 Addresses” (on layer 2) that never leaves the local Ethernet network, just how a MAC address in IPv4 works.