gl/ripetizioni

IP addresses and subnetting in Year 4 at technical institute

In Year 4, Systems and networks opens with IP addressing and subnetting: the bit method, the magic number, three worked exercises.

by Gaetano Livornese

Read the original in Italian

Mid-September 2026, computer science and telecommunications track (Italian Informatica e telecomunicazioni, at technical institutes): in Year 4, the subject Systems and networks (Sistemi e reti) opens the year with the network layer, and in these weeks IPv4 addressing arrives, with subnet masks and subnetting. The first test falls five to eight weeks later, so between the end of October and mid-November — and it is almost always timed, because subnetting is assessed on speed of calculation, not just correctness.

It is the topic on which, in Year 4, half the class falls. Not because it is conceptually hard: because it requires you to reason in binary under time pressure, and in a test there is no room to redo the calculations calmly. The class splits into two groups: those who have understood that all of subnetting rests on reasoning about the bits, and those who try to learn mask tables by heart without understanding where they come from. The first group copes even when the exercise is different from those seen in class; the second gets stuck at the first variation. In this post we look at both methods — the bit method, which is always fine, and the shortcut of the “magic number”, which is faster but requires you to have understood the first in order to know when it applies.

It is worth adding, in two lines and without promising specific career paths: this is also the most directly usable part of the Systems and networks syllabus, because the same skills are the first step of any path as a systems administrator or in networking.

Structure of an IPv4 address

An IPv4 address is a 32-bit number, which for readability we write in dotted decimal notation: four decimal numbers (from 0 to 255, that is each one a byte) separated by a dot, like 192.168.10.5. Each group of 8 bits is called an octet. An IP address, on its own, doesn’t say which part represents the network and which the individual device (host): that information comes from the subnet mask.

Network part, host part, and the subnet mask

Every IP address is divided into two parts: a network part, which identifies the network the device belongs to, and a host part, which identifies the individual device within that network. The subnet mask says where the boundary between the two parts falls: it has all bits at 1 in the network part and all at 0 in the host part.

The mask is written in two equivalent ways:

  • in decimal, like the IP address: 255.255.255.0;
  • in CIDR notation, like /24, where the number indicates how many bits (counted from the left) are dedicated to the network.

/24 and 255.255.255.0 are the same mask: 24 bits at 1 (the first three octets) followed by 8 bits at 0 (the last octet, reserved for the host).

Why classes are mentioned only as historical context

The old classes A, B and C (with fixed masks /8, /16, /24 respectively) are now history: the network today works in classless mode, that is with masks of any length, decided according to how many addresses are really needed — not bound to fixed sizes. It is worth knowing as context to understand where the language comes from (“class C”), but it is not a syllabus to learn by heart: the rest of this post reasons in CIDR, which is how you will really work.

Network address, broadcast, usable hosts

Inside every block of addresses (a subnet), three values have a special role:

  • the network address: the one with all the host-part bits at 0. It identifies the subnet itself, not a device.
  • the broadcast address: the one with all the host-part bits at 1. It is used to send a message to all the devices of the subnet at once.
  • the usable hosts: all the addresses of the subnet except these two extremes.

If a subnet has bits dedicated to the host part, it contains addresses in total, but only can be assigned to devices: the network address and the broadcast address are always subtracted, because they never identify a real host.

Bitwise AND: how to get the network from an address

To find the network address starting from an IP address and its mask, you perform a bitwise logical AND between the two: bit by bit, the result is 1 only if both bits are 1, otherwise it is 0.

Worked example — 192.168.10.130 with mask 255.255.255.192 (/26):

We convert the last octet to binary (the other three stay identical, because the mask has 1 on all their bits): , and the mask on the last octet is .

  10000010   (130, last octet of the address)
& 11000000   (192, last octet of the mask)
----------
  10000000   (128)

The bitwise AND gives . The network address is therefore 192.168.10.128, with mask /26.

Subnetting: dividing a block into smaller subnets

Subnetting consists of “borrowing” bits from the host part of a block to create more, smaller subnets. If you borrow bits, you get subnets, each with the remaining host bits available for addresses.

The two formulas to always keep in mind:

where is the number of borrowed bits and the number of host bits left after borrowing.

The magic number method

Once you have understood the reasoning on the bits, there is a much faster shortcut for listing the subnets: the magic number. It is calculated as minus the decimal value of the mask octet that contains the boundary between network and host. The subnets all start at multiples of that number, in the same octet.

For example, with mask /26 the last octet of the mask is : the magic number is . The subnets therefore start from .0, .64, .128, .192 — exactly every 64 addresses. The magic number works only when you have already understood why those jumps form: it is a calculation shortcut, not a way of skipping the understanding of the bits.

Private addresses: which they are and what they are for

Three blocks of IPv4 addresses are reserved for private networks (those not directly reachable from the internet, like a home or company network): 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Being able to recognise them lets you tell straight away, by looking at an address, whether it belongs to a local network or to the public internet — information that is useful outside this test too, every time you configure a router or read network logs.

Summary table: CIDR, mask, usable hosts

CIDRDecimal mask (last octet)Usable hosts ()
/24255.255.255.0254
/25255.255.255.128126
/26255.255.255.19262
/27255.255.255.22430
/28255.255.255.24014
/29255.255.255.2486
/30255.255.255.2522

Three worked exercises (numbers checked twice)

Exercise 1 — dividing 192.168.10.0/24 into 4 subnets.

To get 4 subnets you need , so bits borrowed from the host part. The new mask is . The magic number is (with /26, the last octet of the mask is 192). The four subnets start every 64 addresses:

SubnetNetwork addressFirst hostLast hostBroadcast
1192.168.10.0192.168.10.1192.168.10.62192.168.10.63
2192.168.10.64192.168.10.65192.168.10.126192.168.10.127
3192.168.10.128192.168.10.129192.168.10.190192.168.10.191
4192.168.10.192192.168.10.193192.168.10.254192.168.10.255

Each /26 subnet has usable hosts (6 host bits left out of 32-26=6). Consistency check: the last host of each subnet is always the broadcast minus 1, and the broadcast is always the address just before the start of the next subnet — here .63 precedes .64, .127 precedes .128, and so on. It matches.

Exercise 2 — finding the network and broadcast of 172.16.37.200/21.

With /21, the boundary between network and host falls inside the third octet (21 network bits = the first two whole octets, 16 bits, plus 5 bits of the third octet; so 3 host bits remain in the third octet plus the whole fourth: host bits in total). We convert the third octet, , to binary: . The mask on the third octet has the first 5 bits at 1 (they are the network bits left after the first two whole octets) and the last 3 at 0: .

  00100101   (37, third octet of the address)
& 11111000   (248, third octet of the mask)
----------
  00100000   (32)

The AND gives . The first two octets stay unchanged (172.16, all network bits), the fourth octet goes entirely to 0 in the network address: network address = 172.16.32.0. For the broadcast, the host bits (the last 3 of the third octet plus the whole fourth) all go to 1: the third octet becomes , the fourth octet is : broadcast = 172.16.39.255. The subnet therefore covers from 172.16.32.0 to 172.16.39.255.

Exercise 3 — at least 50 hosts per subnet are needed: which mask?

You need to find the minimum number of host bits such that . Let’s try:

  • with : . Not enough (30 < 50).
  • with : . Enough (62 ≥ 50).

So 6 host bits are needed, that is a mask with network bits: /26. The mask /27 leaves only 5 host bits, which give 30 usable hosts — not enough for 50 devices, even though the difference between 27 and 26 seems small: each host bit fewer halves the capacity of the subnet.

Typical mistakes that cost marks

Typical mistakeHow you notice it
Forgetting to subtract 2 from usable hostsIf your host count coincides exactly with , you have wrongly included the network and/or broadcast
Counting the subnets required instead of the bits to borrowRecheck with : if the number of subnets you need is not an exact power of 2, round up to the next
Working on the wrong octetFirst identify in which octet the boundary of the CIDR mask falls (divide the prefix by 8), convert only that one to binary
Confusing the mask with the wildcard (its complement)The mask has 1 in the network part; the wildcard, used in other contexts like ACLs, is the exact opposite — they are not the same thing
Giving as broadcast an address that is not the last in the blockThe broadcast must have all 1s in the host part: if it doesn’t coincide with the last address before the next subnet, recheck the bits

For Systems and networks we don’t yet have a dedicated practice test; at /simulazioni/liceo/ you’ll find the high school maths and physics tests, the closest category for practising timed exercises — I’m not promising that a specific practice test on subnetting will arrive, but if it does you’ll find it there.

Whoever arrives at Systems and networks having already digested loops and arrays in Year 3 computer science usually has less difficulty here: step-by-step reasoning on bits requires the same discipline as reading an algorithm line by line before running it. And if at this time you are also preparing the databases, ER model and SQL exam, the method of preparing — sketching on paper before writing — is the same.

For the layers above IP addresses, look at the post on the OSI and TCP/IP model; the syllabus continues in Year 5 with VLANs and security.

Computer science lessons are online, one to one, and on this topic the typical work is exactly redoing the subnetting exercises by hand together, stopwatch in hand, until the bit method becomes automatic. If you’d like a hand, the first introductory call is free and lasts half an hour.

Keep reading

Want to put what you read into practice?

Let's talk for 30 minutes, free: we look together at where you are stuck and I tell you honestly how I can help.

Or message me on WhatsApp.