Networks carry valuable and private data. Security protects it from being read, changed or blocked by attackers.
Security Goals and Threats
Network security aims at the CIA triad: confidentiality (only authorised people read data), integrity (data is not altered) and availability (services remain usable), together with authentication (proving identity) and non-repudiation. Common threats are eavesdropping (sniffing), man-in-the-middle attacks (such as ARP spoofing), spoofing, denial of service (DoS and DDoS), malware, phishing, and attempts to exploit vulnerable services. Defence is built in layers, called defence in depth.
Definition: Firewall. A hardware or software system that monitors and controls network traffic according to security rules, allowing or blocking packets between networks of different trust levels.
Firewalls
A firewall sits between a trusted network and an untrusted one. Packet-filtering firewalls inspect each packet's header (source and destination IP, port, protocol) against an ordered access control list, ending usually with a default deny rule. Stateful firewalls track connections, allowing reply traffic for connections started from inside. Application-layer (proxy) firewalls understand protocols such as HTTP and can inspect content. Next-generation firewalls (NGFW) add deep packet inspection, application awareness and intrusion prevention. Host-based firewalls (Windows Defender Firewall, Linux iptables or ufw) protect a single machine. Public servers are often placed in a DMZ, a separate zone between the internet and the inside network.
Virtual Private Networks
A VPN creates an encrypted tunnel across a public network, so that remote users or branch offices are connected to the private network as if they were on it. Remote-access VPNs connect individual users (for example, staff working from home); site-to-site VPNs connect whole offices. Common protocols are IPsec (at the network layer, with AH for integrity and ESP for encryption, in tunnel or transport mode), SSL/TLS VPNs (such as OpenVPN, through a browser or client) and WireGuard (modern, simple and fast). A VPN provides confidentiality, integrity and authentication, but it does not protect a device that is already infected.
Encryption
Encryption turns plaintext into ciphertext using a key. Symmetric encryption uses the same key for both (AES, ChaCha20); it is fast, but the key must be shared securely. Asymmetric (public-key) encryption uses a public key to encrypt and a private key to decrypt (RSA, elliptic curve); it solves key distribution and enables digital signatures, but is slow. Real protocols such as TLS (in HTTPS) combine them: asymmetric methods to authenticate the server with a certificate and agree on a key, then symmetric encryption for the data. Hash functions (SHA-256) give fixed-length fingerprints that check integrity.
Table 3.8: Security tools and what they protect
| Tool | Protects | Example |
|---|---|---|
| Firewall | Unwanted traffic in or out | iptables, NGFW |
| VPN | Data over public networks | IPsec, WireGuard |
| Encryption | Confidentiality of data | AES, TLS |
| Hash | Integrity of data | SHA-256 |
| IDS/IPS | Detects and blocks attacks | Snort, Suricata |
Example 3.8: Evaluating firewall rules
Problem: A firewall has the rules, checked in order: 1) allow TCP to port 443 from any, 2) allow TCP to port 22 from 10.0.0.0/8, 3) deny all. Decide for: (a) 203.0.113.9 to port 443, (b) 203.0.113.9 to port 22, (c) 10.1.1.5 to port 22, (d) 10.1.1.5 to UDP port 53.
Solution:
- (a) Matches rule 1: allow.
- (b) Not rule 1; rule 2 needs a 10.x source, so no; rule 3: deny.
- (c) Matches rule 2: allow.
- (d) UDP matches neither rule 1 nor 2; rule 3: deny.
Result: Allow (a) and (c); deny (b) and (d). The first matching rule decides.
import ipaddress, hashlib
rules = [("tcp", 443, "0.0.0.0/0", "allow"),
("tcp", 22, "10.0.0.0/8", "allow"),
(None, None, "0.0.0.0/0", "deny")]
def check(proto, port, src):
for p, pt, net, action in rules:
ip = ipaddress.ip_address(src)
inside = ip in ipaddress.ip_network(net)
if p in (None, proto) and pt in (None, port) and inside:
return action
for pkt in [("tcp", 443, "203.0.113.9"), ("tcp", 22, "203.0.113.9"),
("tcp", 22, "10.1.1.5"), ("udp", 53, "10.1.1.5")]:
print(pkt, "->", check(*pkt))
digest = hashlib.sha256(b"hello").hexdigest()
print("SHA-256 of 'hello':", digest[:24], "...")
Output
('tcp', 443, '203.0.113.9') -> allow
('tcp', 22, '203.0.113.9') -> deny
('tcp', 22, '10.1.1.5') -> allow
('udp', 53, '10.1.1.5') -> deny
SHA-256 of 'hello': 2cf24dba5fb0a30e26e83b2a ...
Common mistakes
- Putting a broad "allow all" rule before specific deny rules; the first match wins.
- Thinking a VPN makes a user anonymous or protects an infected device.
- Using a hash as encryption. A hash cannot be reversed to get the data back.
Key takeaways
- Security goals: confidentiality, integrity and availability, plus authentication.
- Firewalls: packet filtering, stateful, proxy and next-generation; rules are checked in order.
- VPNs build encrypted tunnels with IPsec, SSL/TLS or WireGuard.
- Symmetric encryption is fast; asymmetric solves key exchange; TLS combines both.
Practice questions
- What is the CIA triad?
- What is the difference between a remote-access and a site-to-site VPN?
- Why does TLS use both asymmetric and symmetric encryption?
Answers to the practice questions
- Confidentiality, integrity and availability.
- Remote-access connects individual users; site-to-site connects entire networks.
- Asymmetric methods securely authenticate and agree on a key; symmetric encryption then encrypts the data quickly.
Sources
- Official BCA syllabus Computer Networks, course code 26BCA404DS02, Unit III
