Expert · Network security · topic 45 of 57 · 30 min
Firewalls, IPS and VPNs
Explanation
Why firewalls?
Routers move packets as fast as they can. A firewall is a device (or software) whose main job is to decide which traffic is allowed between parts of the network, based on a security policy. It usually sits at the internet edge, and often between internal zones too, such as between the staff network and the data centre.
Zones
Firewalls think in zones: groups of interfaces with the same trust level. A typical design has an inside zone (staff, trusted), an outside zone (the internet, untrusted) and a DMZ (demilitarised zone) for public servers like the company website. The usual policy: inside may start connections to outside and DMZ; outside may reach only specific services in the DMZ; nothing from outside may start a connection to inside.
Packet filter vs stateful firewall
A packet filter, such as a router ACL, looks at each packet on its own: addresses, protocol and ports. It does not remember anything. To let replies come back to inside users, you would have to permit wide ranges of inbound traffic, which is risky.
A stateful firewall keeps a state table (also called a connection table) of every session that started from the inside: source and destination address, ports and protocol. When a reply arrives from outside, the firewall checks the table. If it matches a known session, it is allowed; if not, it is dropped. So inbound traffic is allowed only when an inside user asked for it.
Next-generation firewalls (NGFW)
A next-generation firewall adds deeper checks on top of stateful filtering: application awareness (recognising WhatsApp, YouTube or a database protocol even on unusual ports), user identity (rules by user or group, not just IP), URL filtering, an integrated IPS, malware and file checks, and often TLS decryption for inspection. Cisco Secure Firewall, Palo Alto Networks and Fortinet FortiGate are common examples.
IDS and IPS
| IDS (Intrusion Detection System) | IPS (Intrusion Prevention System) | |
|---|---|---|
| Position | Off to the side; gets a copy of traffic (for example from a SPAN port) | Inline: traffic passes through it |
| Action | Detects and alerts | Detects and blocks in real time |
| Effect on traffic | None; it cannot stop the first packet | Can drop attack packets; adds a little delay |
Both detect attacks with signatures (patterns of known attacks, updated like antivirus) and with anomaly detection (traffic very different from normal). A false positive is normal traffic wrongly flagged; tuning the rules reduces them.
VPNs: private traffic over a public network
Leased private lines between offices are expensive. A VPN (Virtual Private Network) builds an encrypted tunnel across the internet instead. Each packet is wrapped inside another packet: outsiders see only the outer header between the two VPN endpoints, and the content is encrypted.
- Site-to-site VPN: a permanent tunnel between two offices' routers or firewalls. Users do nothing special; the devices handle it. Example: bank branches connecting to the head office data centre.
- Remote-access VPN: one user's laptop or phone connects to the office using a VPN client, with TLS/SSL (for example Cisco Secure Client, formerly AnyConnect) or IPsec. Used by staff working from home or travelling.
What IPsec provides
IPsec is a set of standards for protecting IP packets, used for most site-to-site VPNs. It provides four things:
- Confidentiality: the data is encrypted (for example with AES), so it cannot be read.
- Integrity: a hash (for example SHA-256) shows if a packet was changed on the way.
- Authentication: each end proves who it is, with a pre-shared key or certificates.
- Anti-replay: sequence numbers stop an attacker re-sending old captured packets.
IKE (Internet Key Exchange, UDP 500, or UDP 4500 when NAT is in the path) sets up the keys. ESP (Encapsulating Security Payload) then carries the protected traffic and gives all four protections. AH (Authentication Header) gives integrity and authentication but no encryption, so ESP is what you normally use.
GRE: a tunnel without a lock
GRE (Generic Routing Encapsulation) also wraps packets in a tunnel, and it can carry multicast and routing protocol traffic such as OSPF, which plain IPsec tunnels cannot. But GRE has no encryption by itself. So designs often run GRE inside IPsec (GRE over IPsec): GRE for flexibility, IPsec for security.
Where zero trust fits
Older designs trusted anything inside the network. Zero trust means "never trust, always verify": every user and device must prove who it is, and is checked for health, before it gets access to each application, wherever it is. VPNs, firewalls, 802.1X and MFA are still the building blocks; zero trust changes the mindset from "inside is safe" to "check every request".
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
Firewalls, IPS and VPNs · 1/8
This lesson covers firewalls, intrusion prevention and VPNs, the devices that guard the edges of a network.
Prefer a video by a teacher? Find free videos on “CCNA firewalls IPS IDS site-to-site IPsec remote access VPN explained” on YouTube ↗
In real life: Bank branches linked to head office
A co-operative bank in Maharashtra has 60 branches. Each branch has a small firewall with an internet link and a 4G backup. A site-to-site IPsec tunnel runs from every branch to the data centre in Mumbai, so teller terminals reach the core banking system encrypted, even over the public internet. The data centre firewall is stateful with an IPS turned on, and the internet banking servers sit in a DMZ. Officers working from home use a remote-access VPN with MFA.
Practice (0/3 done)
Which device sits inline and can drop attack traffic as it passes?
Simulate a tiny stateful firewall. Write firewall(packets). Each packet is an object { dir, src, sport, dst, dport, proto } where dir is "out" (inside to outside) or "in" (outside to inside). - Every "out" packet is allowed, and its session is remembered. - An "in" packet is allowed only if it is the reply to a remembered session: its src and sport equal the session's dst and dport, its dst and dport equal the session's src and sport, and the proto is the same. Return an array of "allow" or "drop", one per packet, in order.
A company has a head office in Bengaluru and two branch offices, plus 30 sales staff who travel. Write a short plan (6 to 8 lines) for how they should connect securely, naming the VPN types and what IPsec protects.
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Securing device access: secrets and SSHNetwork security · same module
- Network segmentation, zero trust and VPNsCyber Security: from zero to SOC analyst · Identity and network defence
- Intrusion detection and prevention (IDS/IPS)Cyber Security: from zero to SOC analyst · Identity and network defence
- VPC security and connectivityCloud Computing (AWS, Azure, Google Cloud) · Networking and databases: VPC and RDS
- FirewallsCyber Security: from zero to SOC analyst · Identity and network defence
- Virtualisation, VRFs and cloud networkingAutomation, SDN and cloud networking
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
What lets a stateful firewall allow a reply from a web server back to an inside user?
Answer: Its state table of sessions started from the inside
The firewall remembers the outgoing session and allows only matching replies.
Where should a company place its public web server in a firewall design?
Answer: DMZ
A DMZ lets the internet reach the server while keeping it separate from the trusted inside network.
Which of these does GRE provide by itself?
Answer: A tunnel that can carry multicast and routing protocols
GRE encapsulates traffic, including multicast, but has no encryption; it is often run over IPsec.
Which IPsec service stops an attacker from re-sending captured packets later?
Answer: Anti-replay
Anti-replay uses sequence numbers so old packets are rejected.
An employee working from a hotel connects her laptop to the office. What type of VPN is that?
Answer: Remote-access
A single user connecting with a VPN client uses a remote-access VPN.
A VPN that permanently joins two offices is…Related
Answer: Site-to-site
Site-to-site VPNs link networks, usually with IPsec.
Which device can block traffic as well as alert?Related
Answer: IPS
An IPS is inline and can drop malicious packets.
Which option gives a dedicated private line from your data centre to AWS?Related
Answer: AWS Direct Connect
Direct Connect is a dedicated connection through a partner location. VPN runs over the public internet.
What does a stateful firewall add over a stateless packet filter?Related
Answer: It tracks connections, allowing replies to permitted traffic automatically
It remembers connection state, so you do not need separate rules for replies.
From Firewalls
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- This is the last topic of “Network security”. The module exam comes next.
- Module 9 exam: Network security · 13 questions · 25 min, without help. 5 topics of this module still to finish first.
- Then the next module, Wireless networking. 57 topics left in the course before the final exam.
← Previous: Layer 2 security: port security, DHCP snooping, DAI