0
0
Computer Networksknowledge~30 mins

Firewalls and packet filtering in Computer Networks - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding Firewalls and Packet Filtering
📖 Scenario: You are learning how a firewall protects a home network by controlling which data packets can enter or leave.Imagine a firewall as a security guard checking each data packet against rules before allowing it through.
🎯 Goal: Build a simple list of data packets and a set of filtering rules, then apply the rules to decide which packets are allowed or blocked.
📋 What You'll Learn
Create a list of data packets with specific source IPs and destination ports
Define a configuration variable for allowed destination ports
Use a loop to filter packets based on allowed ports
Mark each packet as 'allowed' or 'blocked' according to the filtering
💡 Why This Matters
🌍 Real World
Firewalls protect home and business networks by controlling which data packets can pass through based on rules.
💼 Career
Network administrators and cybersecurity professionals configure firewalls and packet filters to secure systems from unauthorized access.
Progress0 / 4 steps
1
Create the list of data packets
Create a list called packets with these exact dictionaries representing data packets: {'src_ip': '192.168.1.10', 'dst_port': 80}, {'src_ip': '10.0.0.5', 'dst_port': 22}, {'src_ip': '172.16.0.3', 'dst_port': 443}, {'src_ip': '192.168.1.15', 'dst_port': 25}
Computer Networks
Need a hint?

Use a list with dictionaries. Each dictionary has keys 'src_ip' and 'dst_port'.

2
Define allowed destination ports
Create a list called allowed_ports containing these exact port numbers: 80, 443
Computer Networks
Need a hint?

Use a list with the numbers 80 and 443 exactly.

3
Filter packets based on allowed ports
Create a new list called filtered_packets that contains only the packets from packets where the dst_port is in allowed_ports. Use a for loop with the variable packet to check each packet.
Computer Networks
Need a hint?

Start with an empty list filtered_packets. Use a for loop to check each packet's dst_port. Append allowed packets to the new list.

4
Mark packets as allowed or blocked
Create a new list called final_packets where each packet from packets has an added key 'status' with the value 'allowed' if its dst_port is in allowed_ports, otherwise 'blocked'. Use a for loop with the variable packet.
Computer Networks
Need a hint?

Copy each packet dictionary to avoid changing the original. Add a 'status' key with 'allowed' or 'blocked' based on the port.