The answersDownload the PDF
Worksheet

A12.5 IP addresses and subnets

Networks and the web · A level · AQA 7517 4.9.4.3 · about 30 min

BugBotLab
NameClassDate

What this lesson is about

Network and host identifiers, subnet masks with AND, IPv4 and IPv6, public and private addresses.

Questions 6 marks in all

  1. [1 mark]A host has the address 192.168.10.200 with subnet mask 255.255.255.224. What is its network address?

  2. [1 mark]What does this program print?

    address = 0b10110110
    mask = 0b11110000
    print(address & mask)
  3. [1 mark]How many usable host addresses does a /27 subnet have?

  4. [1 mark]Why was IPv6 introduced?

    1. AIPv4's 32-bit addresses were running out as more devices joined the Internet
    2. BIPv4 could not carry video
    3. CIPv4 addresses could not be written in denary
    4. DIPv4 did not support routers
  5. [1 mark]Which of these are private (non-routable) IPv4 addresses? Choose all that apply.

    Tick every answer that is true.

    1. A10.4.0.1
    2. B172.20.5.5
    3. C192.168.1.1
    4. D172.32.0.1
    5. E8.8.8.8
  6. [1 mark]A host with address 10.1.1.5/24 wants to send to 10.1.2.9. What does it do?

    1. ASends the packet to its default gateway, because ANDing with the mask gives a different network
    2. BSends the packet directly, because both start with 10
    3. CAsks DHCP for a new address
    4. DDrops the packet, because 10.1.2.9 is private

The task: local or through the router?

The robot has the address 192.168.4.70 with prefix length 26. Write to_int(address), which turns a dotted IPv4 string into one integer from 0 to 2<sup>32</sup> − 1, and to_dotted(value), which turns such an integer back into a dotted string. Work the mask out from the prefix length, not by typing it. Then print, one per line: - mask: <dotted mask> - network: <dotted network address>, the robot's address AND the mask - broadcast: <dotted broadcast address>, the network address with every host bit set to 1 - hosts: <n>, the number of usable host addresses Then for each of 192.168.4.100, 192.168.4.130, 172.20.1.9, 8.8.8.8 and 192.168.4.65, in that order, print <address> <where> <kind>: where is local if it is on the robot's subnet and router if not; kind is private if it lies in one of the three private blocks and public otherwise. Use & to find network addresses. That is 9 lines in all. The robot does not drive.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

def to_int(address):
    return 0

def to_dotted(value):
    return "0.0.0.0"

robot, bits = "192.168.4.70", 26

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/a12-5-ip-addresses-and-subnets/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Work out by hand the network address and number of hosts for 172.16.200.9/21, then check with your program.
  2. Write shorten(ipv6) that removes leading zeros from each group of a full IPv6 address.
  3. A network needs 500 hosts. What is the longest prefix length that gives enough addresses?