Defence & Career · Lesson 5 of 6
Network Security Basics: HTTPS, Firewalls, VPNs, Ports and Safe Wi-Fi
How data travels across networks and how it is protected on the way. Learn what HTTPS and TLS really guarantee, how firewalls and ports work, what a VPN does (and does not) do, common network attacks, and safe habits on public Wi-Fi.
Every time you open a website, your request hops across your Wi-Fi router, your internet provider and several networks before it reaches a server — and the reply makes the same journey back. Network security is about making sure nobody along that path can read, change or block what is being sent, and that only the right traffic reaches your systems.
Ports and services in two minutes
An IP address identifies a machine; a port identifies a service on it — like a building address and a flat number. Common ones you should recognise:
| Port | Service | Note |
|---|---|---|
| 22 | SSH (remote login) | Restrict to known IPs; use keys, not passwords |
| 80 / 443 | HTTP / HTTPS | Redirect 80 to 443; serve everything over HTTPS |
| 53 | DNS | Translates names to IP addresses |
| 3306 / 5432 | MySQL / PostgreSQL | Should never be open to the whole internet |
| 3389 | Remote Desktop (RDP) | A favourite ransomware entry point when exposed |
Every open port is a door. The fewer doors facing the internet, the smaller your attack surface.
HTTPS and TLS: what the padlock really means
HTTPS is HTTP protected by TLS. It gives three guarantees:
- Encryption — people on the same Wi-Fi or at your ISP cannot read the traffic.
- Integrity — the data cannot be changed in transit without detection.
- Authentication — a certificate, issued by a trusted certificate authority, proves you are talking to the real domain.
The padlock does not mean "safe site". It means the connection to that domain is encrypted. A phishing site at sbi-kyc-update.in can have a valid padlock too. Always check the domain, not just the lock.
For developers: certificates are free (Let's Encrypt) and automatic on most cloud platforms. Serve everything over HTTPS, redirect HTTP, and add the Strict-Transport-Security (HSTS) header so browsers refuse to downgrade.
Firewalls
A firewall allows or blocks traffic based on rules — source, destination, port and protocol.
- Network firewalls and cloud security groups — "allow 443 from anywhere to the load balancer; allow 5432 only from the app servers".
- Host firewalls — on each machine (Windows Defender Firewall,
ufwon Linux). - Web Application Firewalls (WAF) — inspect HTTP requests for attacks like SQL injection; a useful extra layer, never a replacement for secure code.
Good rule sets start from default deny: block everything, then allow only what is needed.
# A minimal Linux server with ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 203.0.113.10 to any port 22 proto tcp # SSH only from your office/home IP
sudo ufw allow 443/tcp # HTTPS for everyone
sudo ufw enable
sudo ufw status verbose
VPNs: what they do and do not do
A VPN creates an encrypted tunnel between your device and a VPN server.
- Corporate VPNs connect employees securely to internal company systems. Increasingly replaced or complemented by Zero Trust access, where every request is verified based on identity and device health, not on being "inside the network".
- Consumer VPNs hide your traffic from the local network and your ISP — but the VPN provider can see it instead. A VPN does not stop phishing, malware or tracking by the websites you log in to.
Common network attacks
- Man-in-the-middle (MITM) — an attacker positions themselves between you and the server, for example via a fake Wi-Fi hotspot. HTTPS with valid certificates defeats most of these.
- DDoS (Distributed Denial of Service) — floods a service with traffic from thousands of compromised devices to take it offline. Defended with CDNs and DDoS-protection services that absorb the flood.
- DNS spoofing — sending users to a fake address for a real domain.
- Port scanning — automated tools constantly scan the internet for open ports and outdated services. Assume anything exposed will be found within hours.
Safe habits on public Wi-Fi (cafés, stations, hostels)
- Check the exact network name with staff — attackers create look-alike hotspots ("Airport_Free_WiFi").
- Stick to HTTPS sites and official apps; avoid banking on open networks if you can use mobile data.
- Turn off automatic connection to open networks and file sharing on your laptop.
- Keep your device updated — most real compromises use known, already-fixed flaws.
Zero Trust in one line: "never trust, always verify" — no device or user is trusted just because it is on the company network; every access is authenticated, authorised and logged.
Try it yourself: Open any website, click the padlock and view its certificate: who issued it, for which domains, and when it expires. Then, on your own computer, check which ports are listening (netstat -an on Windows, ss -tuln on Linux/macOS) and identify what each one is.
Common interview questions
Try answering each one aloud before you open it.
1What does HTTPS protect against?
It encrypts traffic so it cannot be read in transit, protects integrity so it cannot be altered undetected, and authenticates the server’s domain through a certificate — preventing eavesdropping and most man-in-the-middle attacks. It does not guarantee the website itself is trustworthy.
2What is the difference between a firewall and a WAF?
A network firewall filters traffic by IP addresses, ports and protocols. A web application firewall inspects HTTP requests and responses for application-layer attacks such as SQL injection and XSS.
3What is Zero Trust?
A security model that assumes no implicit trust based on network location; every user, device and request is continuously authenticated and authorised with least privilege, and access is logged.
Practise this
Build something with it
FAQs
Do I need a VPN on public Wi-Fi?
HTTPS already encrypts most of your important traffic. A trustworthy VPN adds protection from the local network, but it does not replace updates, MFA or caution with links.
What is a DDoS attack in simple words?
Thousands of hijacked devices send traffic to one service at the same time, like a crowd blocking a shop entrance, so genuine customers cannot get in.
References & further reading
Finished this lesson?
Mark it complete. Create a free account to save it on every device.