A051 Sa Lab9 - Iptables
A051 Sa Lab9 - Iptables
Experiment 9: IP Tables
Learning Outcomes:
After completion of this experiment, student should be able to
Theory:
Iptables is an extremely flexible firewall utility built for Linux operating systems. iptables is a
command-line firewall utility that uses policy chains to allow or block traffic. When a connection
tries to establish itself on your system, iptables looks for a rule in its list to match it to. If it
doesn’t find one, it resorts to the default action. iptables almost always comes pre-installed on
any Linux distribution. To update/install it, just retrieve the iptables package.
Types of Chains iptables uses three different chains: input, forward, and output.
Input – This chain is used to control the behavior for incoming connections. For example, if a
user attempts to SSH into your PC/server, iptables will attempt to match the IP address and port
to a rule in the input chain.
Forward – This chain is used for incoming connections that aren’t actually being delivered
locally. Think of a router – data is always being sent to it but rarely actually destined for the
router itself; the data is just forwarded to its target. Unless you’re doing some kind of routing,
NATing, or something else on your system that requires forwarding, you won’t even use this
chain.
Procedure:
Do the following task and upload your document along with review questions on
student portal
Page 21
System Administration Lab Manual (2023-24) MPSTME
Page 22
System Administration Lab Manual (2023-24) MPSTME
Task 3: Blocking a particular IP address
sudo iptables –A INPUT –s 10.10.10.10 –j DROP
PING
Page 23
System Administration Lab Manual (2023-24) MPSTME
Task 6: Allowing services from outside which use two way communication
sudo iptables –A INPUT –i eth0 –p tcp - - dport ssh –j ACCEPT
sudo iptables –A OUTPUT –o eth0 -p tcp - - sport ssh –j ACCEPT
Page 24
System Administration Lab Manual (2023-24) MPSTME
Page 25
System Administration Lab Manual (2023-24) MPSTME
Review questions:
1. Explain need for packet filtering firewall.
Firewalls are appliances that protect networks against external intrusion by screening incoming
data and admitting or excluding traffic. Packet filtering firewalls achieve this goal by applying
security rules to data packets. If packets pass these tests, they can enter the network.
iptables is a user-space utility program that allows a system administrator to configure the IP
packet filter rules of the Linux kernel firewall, implemented as different Netfilter modules. The
filters are organized in different tables, which contain chains of rules for how to treat network
traffic packets.
Actually, when we use the DROP command, it will not forward the packet or answer it. But,
simply drops the packet silently. And, no indication is sent to the client or server. But, the REJECT
command sends an error message back to the source indicating a connection failure.
Page 26