T21_96_Vedant Patil
Assignment no:10
Aim :
To study and configure Firewalls using IP tables
Theory:
A firewall is a security tool that oversees and regulates network traffic according to
set rules. It serves as a barrier between trusted internal networks and untrusted
external ones, such as the internet. Firewalls can be deployed as hardware devices,
software programs, or a combination of these.
Types of Firewalls:
• Packet Filtering Firewall: Examines each packet’s source, destination, and port
without assessing connection state.
• Stateful Firewall: Tracks active connections to make decisions based on the traffic
context.
• Application Firewall: Operates at the application layer, inspecting data and
filtering traffic for specific applications or services.
1. iptables Basics
• iptables is a command-line utility in Linux used to set up the firewall rules of
the system.
• It functions by filtering network traffic according to predefined rules
organized into chains: INPUT, OUTPUT, and FORWARD.
o INPUT → manages incoming traffic to the system.
o OUTPUT → manages outgoing traffic from the system.
o FORWARD → manages traffic passing through the system.
2. Listing Rules (iptables -L)
• The command iptables -L displays all firewall rules in various chains.
• The default policy is ACCEPT, allowing all packets unless explicit blocking
rule.
3. Adding Rules (iptables -A and iptables -I)
T21_96_Vedant Patil
• iptables -A appends a new rule at the end of a chain.
• iptables -I inserts a rule at a specific position in a chain.
• Example: iptables -I INPUT 8 -p icmp -j REJECT rejects ICMP (ping) requests.
• Example: iptables -A INPUT -j DROP drops all incoming traffic after other accept
rules.
4. iptables -A INPUT -j DROP
• The rule iptables -A INPUT -j DROP appends a DROP rule to the INPUT chain.
• This blocks all incoming packets unless explicitly allowed earlier.
• It demonstrates how iptables can enforce strict security by rejecting all traffic
except permitted services.
5. ping
T21_96_Vedant Patil
The ping [Link] command fails with the error “Name or service not known.”
• This happens because DNS resolution or ICMP packets are being blocked by
firewall rules.
• It proves that firewall rules directly affect the system’s ability to communicate
over the network.
6. ping Local IP (Successful)
• The command ping [Link] succeeds and shows ICMP replies with zero
packet loss.
• This indicates that local network communication is allowed because ICMP
packets to the internal network are permitted.
• It shows the difference between blocked external traffic and allowed local traffic.
7. iptables -I INPUT -p icmp -j ACCEPT
• This rule re-allows ICMP packets by inserting an ACCEPT rule.
T21_96_Vedant Patil
• Now, ping requests can again be successful.
• This demonstrates how firewall rules can be dynamically modified to enable or
disable specific traffic types.
Conclusion :
This experiment showed how iptables can control network traffic in Linux. By
adding rules, we can allow or block specific protocols and services such as ICMP
(ping), HTTP, FTP, Telnet, and HTTPS. The outputs proved that firewall rules
directly affect connectivity, making iptables an important tool for securing a
system and managing access.