Menu

IP and MAC Addressing

IPv4 addresses

IP is short for Internet Protocol. Every device using this protocol on a network needs an IP address, which identifies that device so data reaches the correct one. The network a device joins gives it this address; it is not fixed in the hardware. That is why the same laptop can have one address at home and a different one at school.

The format of an IPv4 address

An IPv4 address is 32 bits long. It is divided into four 8-bit groups, and four groups of 8 bits make the 32 bits. Each group is displayed as a denary value from 0 to 255, and full stops separate the groups. For example, 156.83.210.44 is an IPv4 address.

Why stop at 255? Because each group is 8 bits, so it has 2 to the power 8 = 256 possible values, counting from 0 up to 255. A group of 274 is impossible, and so is a negative group, because neither can be stored in 8 bits.

An address is only a valid IPv4 address if it has exactly four groups separated by full stops, and every group is a whole number from 0 to 255.

Turning an IPv4 group into binary

Each group converts using the place values 128, 64, 32, 16, 8, 4, 2 and 1. Take the group 210: 128 + 64 + 16 + 2 = 210, so the bits for 128, 64, 16 and 2 are set to 1 and the rest to 0, giving 11010010.

If the total needs fewer than eight bits, pad the front with zeros so the group is still 8 bits: the group 12 becomes 00001100. Doing this to all four groups and joining them gives the full 32-bit address, so 156.83.210.44 is 10011100 01010011 11010010 00101100.

Checking whether an address is valid

AddressValid?Reason
104.62.8.199YesFour groups, all between 0 and 255
47.286.9.2No286 is above 255
88.12.7.abcNoabc is not a whole number
130.14.6.22.5.1NoSix groups