Level 1 · Digital Foundations · Course 1.2 Networking and the Internet

Module 5: IP Addresses and Ports

Goal: understand how devices are found on a network (IP addresses) and how one computer runs many services at once (ports). You'll meet both constantly when you build and host apps.

You'll need: a computer with a terminal (Command Prompt on Windows, Terminal on Mac).

Lessons

  1. 1What an IP address is15–25 minutes✓
  2. 2IPv4 and IPv615–25 minutes✓
  3. 3Public and private addresses, and NAT15–25 minutes✓
  4. 4localhost15–25 minutes✓
  5. 5Ports, TCP and UDP15–25 minutes✓

🛠️Module practice: find your addresses

Write down:

  1. Your private IPv4 address (and IPv6 if you have one).
  2. Your public IP address, from a "what is my IP" search.
  3. Explain in one sentence why they're different.
  4. The result of ping localhost.
  5. The port your browser uses for https:// websites.

✅Module check

Explain in a few sentences, in your own words:

How does a message reach the right program on the right computer?

Show a good answer

A good answer mentions: the IP address finds the right computer (a public address across the internet, with NAT translating to a private address inside a local network); the port number then finds the right program on that computer, such as 443 for a secure website. TCP or UDP carry the data, TCP reliably and UDP quickly.

📝Module quiz

10 questions · 10 marks each · 100 marks in all · pass mark 70% · retry as often as you like ·

1. Your laptop's IP address at home differs from its address at the office. Is something wrong?

Why each option is right or wrong

  • “Yes, a changing address means the laptop has been hacked” (Incorrect): Changing addresses between networks is completely normal and not a sign of hacking.
  • “No, IP addresses change every second to keep you private” (Incorrect): Addresses don't change every second. They stay the same for hours or days on one network.
  • “Yes, it means the laptop's network card is starting to fail” (Incorrect): A working card gets a new address from each network. That's expected, not a fault.
  • “No, each network's router hands out its own addresses” is correct.

    When a device joins a network, that network's router assigns it an address (using DHCP). Your home router and the office router each hand out addresses from their own range, so your laptop gets a different one in each place.

    • Address = location on a network: like a seat number that depends on which hall you're in.
    • Normal behaviour: it even changes on the same network now and then when the lease expires.

📖 Revise: Lesson 1: What an IP address is

Question ID module-05-q1 · Report a mistake in this question
2. Why does every packet carry the sender's address as well as the receiver's?

Why each option is right or wrong

  • “So the router can block packets from unknown senders” (Incorrect): Firewalls can use sender addresses, but that's not why the field exists. Its basic job is to let replies come back.
  • “It doesn't; packets only ever carry the receiver's address” (Incorrect): Every IP packet carries both addresses. Replies depend on it.
  • “So the website can tell which country you are in” (Incorrect): Sites can roughly guess location from an IP address, but that's a side effect, not the reason the field exists.
  • “So the reply knows where to go back” is correct.

    Communication goes both ways. The receiver reads the sender's address from the packet and sends its reply there, like the return address on a letter.

    • Without it: a server could receive your request but have no idea where to send the page.
    • With NAT: your router swaps your private address for its public one on the way out, and swaps it back for replies.

📖 Revise: Lesson 1: What an IP address is

Question ID module-05-q2 · Report a mistake in this question
3. Why was IPv6 created?

Why each option is right or wrong

  • “IPv4 was too slow for modern video streaming services” (Incorrect): Speed depends on links and routing, not on the address format.
  • “To hide websites from people who use older computers” (Incorrect): IPv6 is about addressing, not hiding sites.
  • “To replace Wi-Fi with a faster wireless standard” (Incorrect): Wi-Fi is a way to connect to a local network. IPv6 is an addressing system; they're unrelated.
  • “IPv4 ran out of addresses for the growing number of devices” is correct.

    IPv4 addresses are 32 bits long, allowing about 4.3 billion addresses. With phones, laptops, TVs and sensors, the world needed far more. IPv6 uses 128-bit addresses, an almost unimaginable number.

    • Workaround meanwhile: NAT lets many private devices share one public IPv4 address.
    • Today: both run side by side; many phones already use IPv6.

📖 Revise: Lesson 2: IPv4 and IPv6

Question ID module-05-q3 · Report a mistake in this question
4. Is 192.168.1.300 a valid IPv4 address?

Why each option is right or wrong

  • “Yes, any four numbers separated by dots make a valid address” (Incorrect): The numbers have limits: each must be between 0 and 255.
  • “Yes, as long as the first three numbers are valid” (Incorrect): Every one of the four numbers must be from 0 to 255, including the last.
  • “Only on Linux computers, which allow larger address numbers” (Incorrect): IPv4 rules are the same on every operating system.
  • “No, each of the four numbers must be from 0 to 255” is correct.

    An IPv4 address is four numbers, each stored in 8 bits. Eight bits can hold values from 0 to 255, so 300 can't fit.

    • Why 255: 8 bits give 2⁸ = 256 possible values, 0 to 255.
    • Spot the error fast: any part above 255 makes the address invalid.

📖 Revise: Lesson 2: IPv4 and IPv6

Question ID module-05-q4 · Report a mistake in this question
5. Your laptop shows 192.168.1.24, but a website says your IP is 49.36.x.x. Which is which?

Why each option is right or wrong

  • “They belong to two different laptops on the same home network” (Incorrect): Both describe the same laptop: one inside the home network, one as the world sees it.
  • “49.36.x.x is your laptop's address on mobile data” (Incorrect): You're on home Wi-Fi in this question. The website sees the router's public address, not a separate laptop address.
  • “Both are public addresses that anyone can connect to directly” (Incorrect): 192.168.x.x is a private range. It can't be reached from the internet.
  • “192.168.1.24 is your private home address; 49.36.x.x is your router's public one” is correct.

    Inside your home, the router gives each device a private address. When traffic goes out to the internet, the router replaces it with the one public address your provider gave you. Websites only ever see that public address.

    • This is NAT: network address translation lets many devices share one public address.
    • Private ranges: 192.168.x.x, 10.x.x.x and 172.16–31.x.x are reserved for local networks.

📖 Revise: Lesson 3: Public and private addresses, and NAT

Question ID module-05-q5 · Report a mistake in this question
6. You send a friend http://localhost:3000 to see your app. What will they see?

Why each option is right or wrong

  • “Your project's files, listed so they can download them” (Incorrect): localhost doesn't reach across the internet to your computer.
  • “Your app, exactly as it appears on your own screen” (Incorrect): Their computer would look for an app on itself, not yours.
  • “Your app, but only if you're on the same Wi-Fi network” (Incorrect): Even on the same Wi-Fi, localhost means their own machine. They'd need your laptop's local IP address instead.
  • “Nothing of yours, because localhost means their own computer” is correct.

    localhost is a special name that points to 'this computer'. On your friend's machine it means their own computer, where your app isn't running, so they'll get an error.

    • To share an app: deploy it, or use a tunnelling tool that gives a temporary public link.
    • Same Wi-Fi: they could use your laptop's local address, like 192.168.1.24:3000, if your firewall allows it.

📖 Revise: Lesson 4: localhost

Question ID module-05-q6 · Report a mistake in this question
7. One server runs both a website and a database. How does incoming data reach the right program?

Why each option is right or wrong

  • “By the file name written inside each piece of incoming data” (Incorrect): Network data doesn't carry file names for routing. Ports decide which program receives it.
  • “It's random, and the programs share whatever arrives” (Incorrect): Data delivery isn't random. Ports send each packet to the right program.
  • “By the server's IP address, which differs per program” (Incorrect): One machine usually has one IP address shared by all its programs. Ports tell the programs apart.
  • “Through ports, such as 443 for the web and 5432 for the database” is correct.

    An IP address gets data to the right machine; a port number gets it to the right program on that machine. Each program listens on its own port.

    • Like flats in a building: the street address is the IP; the flat number is the port.
    • Common ports: 80 (HTTP), 443 (HTTPS), 22 (SSH), 5432 (PostgreSQL), 3306 (MySQL).
    • Security: only open the ports the public needs; keep the database port private.

📖 Revise: Lesson 5: Ports, TCP and UDP

Question ID module-05-q7 · Report a mistake in this question
8. Why do video calls use UDP rather than TCP?

Why each option is right or wrong

  • “UDP encrypts the audio, so calls stay private” (Incorrect): UDP has no encryption of its own. Call apps add encryption on top of it.
  • “TCP doesn't work over Wi-Fi, so calls must use UDP” (Incorrect): TCP works fine over Wi-Fi; most web traffic on Wi-Fi is TCP.
  • “UDP is more secure, so private calls are protected” (Incorrect): Neither is secure by itself. Calls add encryption on top.
  • “Speed matters more than perfection; resending lost packets would cause freezes” is correct.

    TCP makes sure every packet arrives, in order, resending any that are lost, which means waiting. In a live call, a packet that arrives late is useless. UDP just sends and moves on, so a lost packet causes a tiny glitch instead of a freeze.

    • TCP fits: web pages, files, emails, where every byte must arrive.
    • UDP fits: live audio, video and games, where 'now' matters more than 'complete'.

📖 Revise: Lesson 5: Ports, TCP and UDP

Question ID module-05-q8 · Report a mistake in this question
9. Can your neighbour's laptop also have the address 192.168.1.24?

Why each option is right or wrong

  • “No, every IP address is unique across the whole world” (Incorrect): Only public addresses are unique. Private ones are reused everywhere.
  • “Only if both laptops are using IPv6 instead of IPv4” (Incorrect): 192.168.1.24 is an IPv4 address; IPv6 doesn't come into it.
  • “Only if the two homes share one router between them” (Incorrect): Separate routers each create their own private network, so the same address can exist in both.
  • “Yes, private addresses repeat in every local network” is correct.

    Private addresses are only meaningful inside one local network. Millions of homes use 192.168.1.x at the same time without conflict, because routers on the public internet don't carry these addresses.

    • Public addresses are unique: your router's public address is yours alone at that moment.
    • Conflict only inside one network: two devices on the same Wi-Fi can't share an address.

📖 Revise: Lesson 3: Public and private addresses, and NAT

Question ID module-05-q9 · Report a mistake in this question
10. Why do developers test new apps on localhost first?

Why each option is right or wrong

  • “It's the only way to run JavaScript on a developer's computer” (Incorrect): JavaScript runs in any browser or Node.js. localhost is about where the server is, not about running JavaScript.
  • “Localhost is always faster than any real server could ever be” (Incorrect): It's quick for one developer, but a production server is built to serve many users.
  • “Browsers block every other address while code is being written” (Incorrect): Browsers don't block other addresses. Developers choose localhost for speed and safety.
  • “It's fast and private, and mistakes don't affect real users” is correct.

    Running an app on your own machine lets you change code and see results in seconds. Nobody else can reach it, so broken experiments don't touch real customers or real data.

    • Fast feedback: no upload or deploy step between change and result.
    • Safe: use test data, break things, start again.
    • Then stage it: test on a server that matches production before going live.

📖 Revise: Lesson 4: localhost

Question ID module-05-q10 · Report a mistake in this question

ProLearners Assist