Introduction to firewalls, ids/ips, and vpns
when computers connect to the internet, they are exposed to risks such as hackers, malware, and unauthorized access. to protect systems and data, networks use security technologies like firewalls, intrusion detection/prevention systems (ids/ips), and virtual private networks (vpns).
think of a company network like a building:
each one plays a different but important role in cybersecurity.
1. firewall
a firewall is a security device or software that controls incoming and outgoing network traffic based on rules.
it acts as a barrier between:
how a firewall works:
firewalls can filter based on:
Types of firewalls:
real-world examples:
simple example of a firewall rule in linux (using iptables):
# block incoming traffic on port 23 (telnet) sudo iptables -A INPUT -p tcp --dport 23 -j DROP
This rule blocks telnet traffic from entering the system.
2. IDS (intrusion detection system)
an intrusion detection system (ids) monitors network traffic and looks for suspicious activity.
important:
how ids works:
types of ids:
example:
if someone tries multiple failed login attempts, ids can detect this and send an alert.
real-world example:
3. IPS (intrusion prevention system)
an intrusion prevention system (ips) is similar to ids but more powerful.
difference:
how ips works:
ips can:
real-world example:
IDS vs IPS comparison
ids:
ips:
4. VPN (virtual private network)
a virtual private network (vpn) creates a secure encrypted connection over the internet.
it allows users to:
how vpn works:
benefits of vpn:
real-world vpn technologies:
example of connecting to openvpn (command line):
sudo openvpn --config myvpnconfig.ovpn
How they work together in real life
example: employee working from home
together, these tools create layered security. this approach is called defense in depth.
Simple python simulation example
below is a simplified simulation of how a firewall and ids might behave logically. this is for learning purposes only.
# simple simulation of firewall and ids
blocked_ports = [23] # telnet blocked
suspicious_ips = ["192.168.1.100"]
def firewall(packet):
if packet["dest_port"] in blocked_ports:
return "blocked by firewall"
return "allowed"
def ids(packet):
if packet["source_ip"] in suspicious_ips:
return "alert: suspicious ip detected"
return "no threat detected"
def process_packet(packet):
fw_result = firewall(packet)
if fw_result == "blocked by firewall":
return fw_result
ids_result = ids(packet)
return f"{fw_result}, {ids_result}"
# example packet
packet = {
"source_ip": "192.168.1.100",
"dest_port": 80
}
print(process_packet(packet))
this code demonstrates:
Why these technologies are important
without firewalls:
without ids/ips:
without vpn:
modern cybersecurity depends on combining these tools to reduce risk and protect sensitive information.
# =========================
# firewall rule example
# =========================
sudo iptables -A INPUT -p tcp --dport 23 -j DROP
# =========================
# openvpn connection example
# =========================
sudo openvpn --config myvpnconfig.ovpn