IP addressing and subnetting interview questions, with answers
Subnetting is the networking topic most often tested with arithmetic, in written rounds and on whiteboards: given an address and a prefix, find the network, the broadcast address and the number of hosts. The arithmetic is simple once the binary is clear, and interviewers use it to check that the definitions are really understood.
The answers below cover IPv4 addresses and CIDR notation, subnet masks, finding a subnet's range, counting hosts, IPv4 versus IPv6, classful addressing and special addresses. Then take the free Computer Networks diagnostic — ten questions across every networking topic in the bank — to see which of these you can explain but not yet apply.
The questions, with answers
1.What is an IPv4 address, and what does CIDR notation mean?
In short: A 32-bit address written as four octets; /n says the first n bits are the network part and the rest identify the host.
An IPv4 address is 32 bits, written as four decimal octets such as 192.168.1.10. It has a network part, shared by every host on the same network, and a host part. CIDR notation writes the length of the network part after a slash: 192.168.1.10/24 means the first 24 bits are the network, so the network is 192.168.1.0/24 and the last 8 bits identify the host. CIDR, classless inter-domain routing, lets networks be any size on a bit boundary rather than only the fixed class A, B and C sizes, which saved address space and made route aggregation possible.
2.How do you find the network and broadcast addresses of a subnet?
In short: Zero the host bits to get the network address and set them all to one to get the broadcast address.
The subnet mask has ones in the network bits, so ANDing the address with the mask zeroes the host bits and gives the network address, and setting all host bits to one gives the broadcast address. A quick method works on the octet the prefix ends in: the block size there is 2 to the power of the host bits in that octet, subnets start at multiples of it, and the address falls in one block. In the example, a /28 has blocks of 16, and 200 falls in the block 192 to 207, so the network is .192, the broadcast is .207, and the hosts are .193 to .206.
10.20.30.200/28 host bits: 4, block: 16 200 is in 192-207 network 10.20.30.192 broadcast 10.20.30.207 hosts .193 to .206
3.How many hosts can a subnet hold?
In short: 2^(32 − prefix) addresses, minus 2 for the network and broadcast addresses: a /28 holds 14 hosts.
A prefix of length n leaves 32 − n host bits, so the subnet has 2^(32 − n) addresses. Two of them are reserved: the all-zeros host part is the network address and the all-ones host part is the broadcast address, so usable hosts number 2^(32 − n) − 2; a /28 has 16 addresses and 14 hosts. To size a subnet for a requirement, choose the smallest block whose usable count covers it, remembering the router's own address. Point-to-point /31 links, which use both addresses, and single-host /32 routes are exceptions to the rule.
4.What is the difference between IPv4 and IPv6?
In short: IPv6 uses 128-bit addresses instead of 32-bit, with a simpler header, no broadcast, and built-in autoconfiguration.
IPv4 addresses are 32 bits, about 4.3 billion in total, which ran out, forcing heavy use of NAT. IPv6 addresses are 128 bits, written as eight groups of hexadecimal digits such as 2001:db8::1, with runs of zero groups shortened to ::. IPv6 also has a fixed-length, simpler header, leaves fragmentation to the sending host, replaces broadcast with multicast, replaces ARP with Neighbor Discovery, and lets hosts configure their own addresses with SLAAC. The two are not directly compatible, so networks run both side by side (dual stack) or translate between them.
5.What were address classes, and why was classful addressing replaced?
In short: Class A, B and C gave fixed /8, /16 and /24 networks; the sizes wasted addresses, so CIDR replaced them in 1993.
Classful addressing fixed the network size by the first bits of the address: class A (first octet 1 to 126) had an 8-bit network part and about 16 million hosts, class B (128 to 191) 16 bits and about 65,000 hosts, class C (192 to 223) 24 bits and 254 hosts, class D was multicast and class E reserved. The rigid sizes wasted address space, since an organisation needing 2,000 addresses had to take a whole class B, and they bloated routing tables. CIDR removed the classes, allowing any prefix length and aggregation of routes. The class names survive mainly in textbooks.
6.What are the special IPv4 addresses such as 127.0.0.1 and 0.0.0.0?
In short: 127.0.0.0/8 is loopback, 0.0.0.0 means this host or any address, 255.255.255.255 is limited broadcast, and 169.254.0.0/16 is link-local.
Several ranges have special meanings. 127.0.0.0/8 is the loopback range: 127.0.0.1, localhost, reaches the host itself without touching the network. 0.0.0.0 means this host, used as a source address before a host has one, and a server bound to 0.0.0.0 listens on every interface. 255.255.255.255 is the limited broadcast, delivered to every host on the local network but never forwarded by routers. 169.254.0.0/16 is link-local, self-assigned when DHCP fails, and 224.0.0.0/4 is multicast.
How the diagnostic asks it
One question from the Computer Networks bank, exactly as a sitting would show it. The bank has 4 on ip addressing & subnetting and 30 across Computer Networks.
What are the network address and the broadcast address of the subnet containing 192.168.10.77/27?
- 1Network 192.168.10.32, broadcast 192.168.10.63
- 2Network 192.168.10.64, broadcast 192.168.10.95correct
- 3Network 192.168.10.64, broadcast 192.168.10.127
- 4Network 192.168.10.72, broadcast 192.168.10.79
A /27 leaves 5 host bits, so subnets come in blocks of 32 in the last octet: 0, 32, 64, 96 and so on. 77 falls in the block starting at 64, so the network address is 192.168.10.64, with all host bits zero, and the broadcast address is 64 + 32 − 1 = 95, with all host bits one. The .32 block is the previous subnet, which ends at 63. Broadcast .127 belongs to the /26 containing 77, and .72 to .79 is the /29.
Measure it
Reading answers tells you what’s true. A diagnostic tells you what you get wrong.
10 Computer Networks questions across its topics, easy to hard, about fifteen minutes. You get a readiness figure with the arithmetic shown, the topics you missed named, and a practice set sized for today. Free: 1 diagnostic a month and 15 problems a day. No card.