Sign inSign up free

1021. Find Overlapping Subnets Before They Bite

medium 20 XP ~10 minHands-on lab

The team keeps its network allocations in a text file, one NAME CIDR per line (comments start with #, blank lines are ignored). Two VPN connections broke last month because their ranges overlapped with an existing one.

Task

Create the executable script /home/student/bin/overlaps.sh FILE that:

  • prints INVALID <name> <cidr> for each entry that isn't a valid network (host bits set, like 10.0.1.5/24, counts as invalid),
  • prints OVERLAP <a> <b> for every pair of valid entries whose ranges overlap, with a the entry that comes first in the file, pairs ordered by the position of a and then b,
  • exits 2 if any entry is invalid, else 1 if any overlap was found, else 0.

IPv4 and IPv6 networks never overlap each other. Try it on /home/student/networks.txt.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Part of Networking and TLS in Practice. Next step: Normalize IPv6 Addresses

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.