Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

10. Linux Firewall rules configuration by Iptables.

Description: iptables controls the ports on a network interface where the packets will enter and exit.
if we don’t want to allow the traffic from a specific port we can close the port.

Theory:

IP tables is a rule based firewall system and it is normally pre-installed on a Unix Operating System
which is controlling the incoming and outgoing packets. By default the IP tables is running
withoutany rules, we can create, add, editrules into it.

IP tables is used to set up, maintain, and inspect the tables of IPpacket filter rules in the Linux kernel.
Several different tables may be defined. Each table contains a number of built-in chains and may also
contain user-defined chains. Each chain is a list of rules which can match a set of packets. Each rule
specifies what to do with a packet that matches. This is called a ‘target’, which may be a jump to a
user-defined chain in the same table.

Basic structure of IP tables:

Tables —> Chains —> Rules Types of Chains:

It is the default table in IP tables. There is no need to specify the table name for defining the Rules.
Different inbuilt chains in this table.

1. INPUT Chain

This chain handles all packets that are addressed to your server.

2. FORWARD Chain

This chain is used to deal with traffic destined for other servers that are not created on your
server. This chainis basically a way to configure your server to route requests to other
machines.

3. OUTPUT Chain

This chain control packets from the server to outside. Here we can add different rules to
manage outbound connection from the server.

Targets:

Each and every chain contain three types of targets. Those are

1. ACCEPT: for accepting a rule


2. REJECT: when you want the other end to know the port is unreachable
3. DROP:it drops packets dead and will not carry out any further processing

RULES:
1. Displaying list of chains
-L : For displaying list of chains
-n: for displaying IP address and port number in numeric format
-v : for displaying the rules in detail
--line-numbers : to display rules in line numbers
Procedure:

1. Iptables -L

2. Find Ipadress of the gmail

3. find range of 142.250.205.229

4. iptables -A OUTPUT -d 142.250.0.0/15 -j DROP


Delete the rule:

5. iptables –D OUTPUT -d 142.250.0.0/15 -j DROP


6.To avoid ping connection
Iptables -A INPUT -d 142.250.0.0/15 -j DROP

Delete the rule:

7. iptables –D INPUT -d 142.250.0.0/15 -j DROP

You might also like