Autocoder

IP Addressing and Subnetting Interview Questions with Worked Solutions

Last updated 2026-11-19

Subnetting is the most calculation-heavy part of networking interviews and written tests. The problems repeat in a few shapes: find the network and broadcast address of a host, split a block into equal subnets, allocate different-sized subnets with VLSM, or aggregate several networks into one prefix. This page solves each shape with the working shown, so the method is clear and can be repeated on new numbers.

The one trick behind most of them is the block size: 256 minus the interesting octet of the mask. Once you can find that, every network and broadcast address follows quickly. For the surrounding concepts see computer networks interview questions, and for how routers use prefixes, routing protocols interview questions. The test prep side is covered in how to crack a technical MCQ test.

Host formulaUsable hosts = 2^h - 2 for h host bits
Block size256 minus the mask value in the octet where the subnet boundary falls
NumericalsNetwork and broadcast, equal split, VLSM, supernet, same-subnet check

Method for any subnetting question

IP Addressing and Subnetting Interview Questions with Worked Solutions: questions with worked answers

  1. 1

    What are the IPv4 address classes and their ranges?

    easy

    Class A: first octet 1 to 126, default mask /8 (255.0.0.0), 16,777,214 hosts per network. Class B: 128 to 191, /16, 65,534 hosts. Class C: 192 to 223, /24, 254 hosts. Class D: 224 to 239, multicast. Class E: 240 to 255, reserved. 127.0.0.0/8 is loopback. Classful addressing has been replaced by CIDR, which allows any prefix length.

  2. 2

    What are the private IPv4 ranges and other special addresses?

    easy

    Private (RFC 1918): 10.0.0.0/8, 172.16.0.0/12 (172.16.0.0 to 172.31.255.255) and 192.168.0.0/16. These are not routable on the internet and need NAT to reach it. Others: 127.0.0.0/8 loopback, 169.254.0.0/16 link-local (APIPA, assigned when DHCP fails), 0.0.0.0 meaning this host or any address, and 255.255.255.255 the limited broadcast.

  3. 3

    How many usable hosts are in a /24, /26 and /30 network?

    easy

    Usable hosts = 2^h - 2, where h = 32 - prefix, because the all-zeros host is the network address and the all-ones host is the broadcast address. /24: 2^8 - 2 = 254. /26: 2^6 - 2 = 62. /30: 2^2 - 2 = 2, the classic point-to-point link. A /31 has no network or broadcast address and gives 2 usable addresses for point-to-point links (RFC 3021).

  4. 4

    Numerical: Find the network address, broadcast address and usable range of 192.168.10.77/26.

    medium

    /26 gives mask 255.255.255.192 and block size 256 - 192 = 64. The last-octet networks are 0, 64, 128, 192. 77 lies in 64 to 127, so the network is 192.168.10.64 and the broadcast is 192.168.10.127. Usable addresses are 192.168.10.65 to 192.168.10.126, which is 62 hosts.

  5. 5

    Numerical: Find the network and broadcast for 172.16.45.200/20.

    medium

    /20 mask is 255.255.240.0 (the third octet has 4 network bits: 11110000 = 240). Block size in the third octet = 256 - 240 = 16. 45 lies in 32 to 47, so the network is 172.16.32.0 and the broadcast is 172.16.47.255. Hosts = 2^12 - 2 = 4094, usable range 172.16.32.1 to 172.16.47.254.

  6. 6

    Numerical: Split 192.168.1.0/24 into 4 equal subnets. Give each network, range and broadcast.

    medium

    4 subnets need 2 extra bits, so the new prefix is /26 (mask .192, block size 64, 62 hosts each). Subnet 1: 192.168.1.0/26, hosts .1 to .62, broadcast .63. Subnet 2: 192.168.1.64/26, hosts .65 to .126, broadcast .127. Subnet 3: 192.168.1.128/26, hosts .129 to .190, broadcast .191. Subnet 4: 192.168.1.192/26, hosts .193 to .254, broadcast .255.

  7. 7

    Numerical: A company needs 6 subnets from 200.1.1.0/24. What is the mask, and how many hosts per subnet?

    medium

    6 subnets need 3 bits since 2^3 = 8 is the smallest power of two that is at least 6 (2^2 = 4 is too few). Prefix = 24 + 3 = /27, mask 255.255.255.224, block size 32. Hosts per subnet = 2^5 - 2 = 30. Two of the 8 subnets are unused. The subnet networks are .0, .32, .64, .96, .128, .160, .192 and .224.

  8. 8

    Numerical: A class B network 172.16.0.0 needs at least 100 subnets. Give the mask and hosts per subnet.

    medium

    2^7 = 128 is the smallest power of two that is at least 100, so borrow 7 bits: prefix = 16 + 7 = /23, mask 255.255.254.0. Host bits = 32 - 23 = 9, so each subnet has 2^9 - 2 = 510 usable hosts. The subnets increment by 2 in the third octet: 172.16.0.0, 172.16.2.0, 172.16.4.0, and so on.

  9. 9

    Numerical (VLSM): Allocate subnets from 192.168.5.0/24 for departments needing 100, 50, 25 and 10 hosts.

    hard

    Allocate largest first, with the smallest block that fits hosts + 2. 100 hosts need 128 addresses (/25): 192.168.5.0/25, range .1 to .126, broadcast .127. 50 hosts need 64 (/26): 192.168.5.128/26, range .129 to .190, broadcast .191. 25 hosts need 32 (/27): 192.168.5.192/27, range .193 to .222, broadcast .223. 10 hosts need 16 (/28): 192.168.5.224/28, range .225 to .238, broadcast .239. Addresses .240 to .255 remain free. Total used = 128 + 64 + 32 + 16 = 240 of 256.

  10. 10

    Numerical (supernetting): Aggregate 192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24 and 192.168.3.0/24.

    medium

    Write the third octets in binary: 0 = 00000000, 1 = 00000001, 2 = 00000010, 3 = 00000011. The first 6 bits of the third octet are common, so the common prefix is 16 + 6 = 22 bits. The aggregate is 192.168.0.0/22 (mask 255.255.252.0), covering 192.168.0.0 to 192.168.3.255. Aggregation requires contiguous blocks and the first block to be aligned on the size of the whole, here a multiple of 4 in the third octet.

  11. 11

    Numerical: Are 10.1.1.100/25 and 10.1.1.130/25 in the same subnet?

    medium

    /25 has block size 128 in the last octet, so networks are 10.1.1.0 (hosts .0 to .127) and 10.1.1.128 (hosts .128 to .255). 100 is in the first, 130 in the second, so they are in different subnets and need a router to communicate. Quick method: AND each address with the mask and compare the results.

  12. 12

    Convert a prefix to a mask and a wildcard mask: /20, /26 and /29.

    medium

    /20: 255.255.240.0, wildcard 0.0.15.255. /26: 255.255.255.192, wildcard 0.0.0.63. /29: 255.255.255.248, wildcard 0.0.0.7. The wildcard mask is the inverse (255 minus each octet) and is used in ACLs and OSPF network statements. Handy values for the interesting octet: 128, 192, 224, 240, 248, 252, 254, 255 for 1 to 8 network bits.

  13. 13

    Verify subnet calculations with code.

    medium

    Python's ipaddress module does network, broadcast, host count and subnet splitting, which is a good way to check hand calculations.

    python
    import ipaddress
    n = ipaddress.ip_network("192.168.10.77/26", strict=False)
    print(n.network_address, n.broadcast_address, n.num_addresses - 2)
    # 192.168.10.64 192.168.10.127 62
    
    for s in ipaddress.ip_network("192.168.1.0/24").subnets(new_prefix=26):
        print(s)                      # 4 subnets of 64 addresses
    
    print(ipaddress.ip_address("10.1.1.130") in
          ipaddress.ip_network("10.1.1.0/25"))   # False
  14. 14

    What is DHCP and how does it assign an address?

    medium

    The Dynamic Host Configuration Protocol gives hosts an IP address, mask, default gateway and DNS servers automatically for a lease period. It follows four steps, DORA: the client broadcasts Discover (UDP port 68 to 67), a server replies with Offer, the client broadcasts Request for the chosen offer, and the server sends Acknowledgement. The client renews at 50 percent of the lease. A relay agent forwards the broadcasts to a central server on other subnets.

  15. 15

    What are the main features of IPv6 and how do you shorten an IPv6 address?

    medium

    IPv6 has 128-bit addresses (about 3.4 x 10^38), a fixed 40-byte header with no checksum and no router fragmentation, built-in autoconfiguration (SLAAC), and neighbour discovery in place of ARP. To shorten, drop leading zeros in each 16-bit group and replace one longest run of all-zero groups with ::, once. So 2001:0db8:0000:0000:0000:ff00:0042:8329 becomes 2001:db8::ff00:42:8329. ::1 is loopback, fe80::/10 link-local and 2000::/3 global unicast.

  16. 16

    Why is NAT used, and how does IPv6 change the need for it?

    hard

    IPv4 has only about 4.3 billion addresses, so NAT lets many private hosts share one public address by translating address and port pairs. It makes inbound connections hard and complicates some protocols. IPv6 provides enough addresses that every device can have a globally unique address, so NAT is no longer needed for scarcity, and firewalls provide the protection NAT incidentally gave. Transition uses dual stack, tunnelling or NAT64.

Frequently asked questions

What is the fastest way to find the network address?

Find the block size (256 minus the mask octet), then the largest multiple of it that does not exceed the host's octet. Everything before that octet is copied, and the octets after it are zeros.

Why do we subtract 2 from the number of addresses?

The first address of a subnet identifies the network and the last is the directed broadcast address, so neither can be assigned to a host.

What is CIDR?

Classless Inter-Domain Routing writes a network as an address plus prefix length, such as 203.0.113.0/24, and allows any prefix length with route aggregation, replacing rigid class A, B and C networks.

What is the default gateway?

The router address on the local subnet that a host sends traffic to when the destination is outside its subnet. It must be inside the host's own subnet.

Related guides

More in CS Fundamentals Interview Questions

See all in this section