Please enable JavaScript to use CodeHS

Cybersecurity Tutorial

Network Management

Is the wifi down, or is the website down? Learn how devices find each other on a network, and use the same commands the pros use to see your connection, test it, and trace it across the internet.

ping traceroute ~20 min Beginner friendly
The Big Idea

What is a network?

A network is a group of devices that can talk to each other: your laptop, your phone, the family printer, and the router that connects them all to the internet. When you load a website, your computer doesn't grab one giant file. It sends and receives lots of tiny chunks of data called packets that travel back and forth between your device and a far-away server.

In the Command Line Interface tutorial, you used the CLI to explore files and programs on your own computer. But the CLI can reach way past your keyboard. With a few network commands you can see your computer's network settings, test whether another machine is reachable, and even watch the exact route your packets take across the internet.

New here? This tutorial builds on the command line basics. If words like "terminal" and "command" feel new, do the Command Line Interface tutorial first, then come back.

Why bother? Because networks break. The wifi drops, a website won't load, a game keeps lagging. Network commands turn "the internet is broken!" into an actual investigation: is the problem my computer, my router, or the website itself? By the end of this page you'll know exactly which command answers which question.

Addresses

Two kinds of addresses: IP and MAC

For packets to find their way, every device needs an address. Devices actually have two, and they do different jobs:

IP address
192.168.1.42
  • Like your street address: it says where you are on the network right now
  • Assigned by the network, so it can change when you join a new one
  • What packets use to find your device
MAC address
a4:83:e7:2c:91:5b
  • Like a serial number: it identifies the device's network hardware itself
  • Burned in at the factory, so it stays the same everywhere
  • Used by devices talking on the same local network

Think of it this way: if your laptop moves from home to school, its street address (IP) changes because it lives somewhere new, but its serial number (MAC) is still the same laptop. In a minute you'll use a command that shows you both.


Behind the Scenes

How the internet finds a website

You type codehs.com, not 34.213.108.87. But packets only understand numbers. So every website visit starts with a quick translation, then a relay race:

Step 1

You type a name

You ask your browser for a website by its human-friendly name.

codehs.com
Step 2

DNS looks up the IP

A DNS server works like the internet's phone book and returns the number.

34.213.108.87
Step 3

Packets hop to it

Your packets jump router to router until they reach that IP, then the reply hops back.

6 hops, 61 ms

Each router your packet passes through is called a hop. Routers use a routing table, basically a map, to decide where to send each packet next. Your request might hop through your home router, your internet provider, and several big internet backbones before it arrives, usually in well under a tenth of a second.


The Toolkit

The network commands

Here are the five commands every network detective keeps in their belt. The exact names vary a little by operating system: Mac and Linux use ifconfig and traceroute, while Windows uses ipconfig and tracert. Same ideas, slightly different spelling.

ifconfig / ipconfig Is it me?

Shows the network settings of your own computer: its IP address, its MAC address, and whether each network adapter (like wifi) is up and running. If a page won't load, start here. No IP address usually means you're not really connected to the network at all.

With admin (superuser) permissions, these commands can even turn network adapters on and off.

ping Can I reach it?

Sends small test packets to another computer and waits for replies, like shouting "Marco!" and listening for "Polo!" Each reply shows the round-trip time in milliseconds. When you stop, you get statistics: how many packets made it and how many were lost. Replies mean the site is reachable. Timeouts mean something between you and it is broken.

traceroute / tracert Which path?

Follows your packets on their journey and prints every hop along the way with how long it took. It's a road map of your request crossing the internet. If a connection is slow or failing, traceroute shows you where along the route things go wrong. (Windows also has pathping, which combines tracert with ping to find hops that delay or drop packets.)

netstat Who's connected?

Lists all the active connections and listening ports on your computer: every conversation your machine is currently having over the network. It can also display the routing table. Security pros love this one for spotting connections that shouldn't be there.

nslookup What's its number?

Asks a DNS server to translate a website name into its IP address, the "phone book lookup" from the diagram above. If nslookup fails but ping to a raw IP works, you know the problem is DNS, not your connection.

The detective's order: wifi acting up? Try ifconfig (is my computer connected?), then ping a website (can I reach the outside world?), then traceroute (where exactly does it break?). Three commands, mystery solved.

Interactive

Try it: your network terminal

Welcome to your own network operations terminal. It simulates a real one, so nothing you type here can break the internet. Complete these missions (stuck? reveal a hint):

1Find your computer's IP address

Use the command that shows your own machine's network settings. Bonus: spot the MAC address too.

ifconfig (look for "inet 192.168.1.42" and the "ether" row)

2Check if codehs.com is reachable

Send test packets to codehs.com and read the statistics. Then try ping brokensite.test to see what a failure looks like.

ping codehs.com ping brokensite.test (compare "0% packet loss" with "100% packet loss")

3Count the hops to codehs.com

Trace the route your packets take. How many routers do they pass through, and how does the time change with each hop?

traceroute codehs.com (each numbered row is one hop; count them)
net-cadet@noc-1 · network terminal ONLINE
net-cadet@noc-1:~$

Click the terminal, type a command, and press Enter. Type help to list every command it understands, and clear to wipe the screen. Press the up arrow to repeat a command.


Cheat Sheet

Command reference

Keep this table handy the next time the wifi gets weird. Mac/Linux names are listed first with the Windows version after the slash.

CommandWhat it showsExample
ifconfig / ipconfigYour own computer's network settings: IP address, MAC address, adapter statusifconfig
pingWhether another computer is reachable, reply times, and how many packets were lostping codehs.com
traceroute / tracertEvery router hop your packets pass through on the way, with timing for eachtraceroute codehs.com
pathpingWindows combo of tracert + ping: finds hops with delays or packet losspathping codehs.com
netstatAll active connections and listening ports; can also show the routing tablenetstat
nslookupThe IP address behind a website name (a DNS lookup)nslookup codehs.com
netsh / networksetupTools for changing network settings (needs admin permissions)netsh interface show interface

Check Yourself

Quick quiz

1. Your wifi seems broken and you want to check your OWN computer's IP address first. Which command do you run?

2. You run ping brokensite.test and every packet says "Request timeout", ending with 100% packet loss. What does that tell you?

3. Which address works like a serial number that stays with a device's hardware, even when it joins a different network?

Keep exploring cybersecurity

You can now read a network like a map: check your own settings, ping a host, and trace packets across the internet. Keep sharpening those command line skills, or start investigating like a digital detective.