The guard at the gate
A big office has a guard at the gate. The guard has a list. Delivery vans may come in. Visitors need a pass. Nobody may carry a box out without a note.
A computer network (linked computers) has a guard like that. It checks everything that comes in and goes out, using a list of rules.
Key words
| Word | What it means | Example |
|---|---|---|
| Network | Computers and devices linked together. | a school network |
| Firewall | A guard that allows or blocks network traffic using rules. | a gate with a list |
| Inbound | Traffic coming into your network. | a visitor to your website |
| Outbound | Traffic going out of your network. | a worker opening a web page |
| Port | A numbered door on a computer for network traffic. | port 443 for secure web pages |
| IP address | The number that names a device on a network. | 192.168.1.20 |
| Segregation | Keeping parts of a network apart. | a guest network and a staff network |
| Network monitoring | Watching network traffic and logs for problems. | a screen of alerts |
| Port scanning | Checking which ports are open on a computer. | a list of open doors |
The cells students fill in are left blank in this preview.
Quick check: in or out?
Have a go
Quick check: in or out?
3 questionsA firewall between two networks
flowchart LR
internet([The internet]) -->|inbound traffic| fw{Firewall rules}
fw -->|allowed| office[Company network]
fw -.->|blocked| bin[Dropped]
office -->|outbound traffic| fw
Four kinds of firewall rule
| Kind of rule | It decides by | Example | Why use it |
|---|---|---|---|
| Traffic direction | Whether it is inbound or outbound | Block all inbound traffic unless asked for | Strangers cannot start a chat with your computers |
| Traffic type | The kind of traffic, such as web pages or email | Allow web traffic. Block file sharing | Stops kinds of traffic the business does not need |
| Application | Which program sends it | Block a game, allow the work program | Stops unwanted programs sending data out |
| IP address | Where it comes from or goes to | Block a list of addresses known to attack | Shuts out sources that are known to be bad |
The cells students fill in are left blank in this preview.
In a rule list, the first match wins
| Rule | Action | Direction | Port | Meaning |
|---|---|---|---|---|
| 1 | Allow | Inbound | 443 | Visitors may reach secure web pages |
| 2 | Deny | Inbound | 23 | Nobody may use door 23 |
| 3 | Allow | Outbound | any | Staff may go out to the internet |
| 4 | Deny | Everything else | any | Default: block what is not listed |
The cells students fill in are left blank in this preview.
Which rule would you write?
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Extra: Some real port numbers
| Port | What uses it | Usual rule |
|---|---|---|
| 443 | Secure web pages (HTTPS) | Allow |
| 80 | Web pages that are not secure | Often sent on to 443 |
| 22 | Secure login to a computer from far away | Allow only for staff |
| 23 | Telnet, an old login that sends passwords as plain text | Deny |
| 3389 | Remote desktop (using a computer from far away) | Deny from the internet |
The cells students fill in are left blank in this preview.
Try it: first match wins
rules = [["allow", "in", 443], ["deny", "in", 23], ["allow", "out", "any"]]
def decide(direction, port):
for rule in rules:
if rule[1] == direction and (rule[2] == "any" or rule[2] == port):
return rule[0]
return "deny"
print(decide("in", 443))
print(decide("in", 23))
print(decide("in", 8080))
# Add a new rule at the start to allow port 8080 and run it again.
Make a free account to save your work and track your progress.
Keep the parts apart
Segregation means keeping parts of a network apart. If an attacker gets into one part, they cannot walk into the rest.
Three ways: virtual (one set of cables, split by software), physical (separate cables and network boxes), and offline (no connection at all).
A segregated network
flowchart TD
net([Internet]) --> fw{Firewall}
fw --> guest[Guest Wi-Fi zone]
fw --> office[Office zone]
fw --> servers[Server zone]
office --> servers
vault[(Offline vault: no network)]
Three ways to segregate
| Way | How | Benefit | Drawback |
|---|---|---|---|
| Virtual | Software splits one network into zones | Cheap and easy to change | A software mistake can join zones again |
| Physical | Separate cables and network boxes | Strong split | Costs more. Harder to change |
| Offline | Not connected to any network | Cannot be attacked over a network | Slow. Data moves by hand |
The cells students fill in are left blank in this preview.
Your turn: build a tiny firewall
Build a tiny firewall. The first function reads a list of rules: the first match wins, and the default is deny. The second blocks addresses on a list. The third says if two zones may talk. Press Run Tests.
def decide(rules, direction, port):
# rules is a list of rules, in order. Each rule is a list: [action, direction, port].
# For example ["allow", "in", 443].
# A port of "any" matches every port. The FIRST rule that matches wins.
# If no rule matches, the answer is "deny" (default deny).
return ""
def ip_allowed(ip, blocked_ips):
# False if the address is on the blocked list.
return True
def can_talk(zone_a, zone_b, allowed_pairs):
# allowed_pairs is a list of pairs, like [["office", "servers"]].
# The two zones in a pair may talk, in either direction.
# Give back True only if the two zones are the same, or the pair is allowed.
return True
Make a free account to save your work, or press Start lab to work through the whole lesson.
Monitoring spots strange traffic
Network monitoring means watching traffic and logs all the time. It spots strange things: many wrong passwords, a big file going out at 3am, or a device talking to a bad address.
Port scanning finds open ports. Owners scan their own network to shut doors that should be closed. Attackers scan too.
Extra: Before the lab: the one rule
Warning
The next lab gives you copied logs from a made-up attack, on your own machine. Press Start the lab on the bar at the top and wait until it is running. Never scan or probe a network that is not yours. It can break the law, such as the Computer Misuse Act 1990. It can also break college rules.
Extra: 1. See the evidence files
find case -type fA command for the lesson’s lab terminal. It is shown here and not run.
Extra: 2. Read a few log lines
head -n 5 case/var/log/auth.logA command for the lesson’s lab terminal. It is shown here and not run.
Extra: 3. Count the failed passwords
grep -c "Failed password" case/var/log/auth.logA command for the lesson’s lab terminal. It is shown here and not run.
Scenario: what went wrong?
Have a go
Scenario: what went wrong?
4 questionsKey words crossword
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Final check
Have a go