LAB - Chapter 10.1 - Firewall - IPTable
LAB - Chapter 10.1 - Firewall - IPTable
Introduction
Characteristic
IPTable Package
Packet Processing
IPTable Table
o Filter
o NAT
o MANGLE
Practice
04/11/2022 2
1
04/11/2022
04/11/2022 3
04/11/2022 4
2
04/11/2022
04/11/2022 5
3
04/11/2022
You can start, stop, and restart iptables after booting by using the
commands:
o Starting IP tables: service iptables start
o Stopping IP tables: service iptables stop
o Restaring IP tables: service iptables restart
o Checking IP tables status (rulechains): service iptables status
To get iptables configured to start at boot, use the chkconfig
command: chkconfig iptables on
iptables itself is a command which we will see soon.
To show all current rule chains: iptables –-list
To drop all current rule chains: iptables –-flush
2. FILTER: packet filtering, has three builtin chains (your firewall policy rules)
o Forward chain: filters packets to servers protected by firewall
o Input chain: filters packets destinated for the firewall
o Output chain: filters packets orginating from the firewall
4
04/11/2022
PC PC
(source) (source)
Server
(source)
PC PC
(destination) (destination)
04/11/2022
Output chain: filters packets orginating from the firewall9
Server
(forward)
PC PC
(source) (destination)
10
04/11/2022
5
04/11/2022
Each firewall rule inspects each IP packet and then tries to identify it
as the target of some sort of operation. Once a target is identified,
the packet needs to jump over to it for further processing
ACCEPT
o iptables accepts further processing.
o The packet is handed over to the end application or the operating
system for processing
DROP
o iptables stops further processing.
o The packet is blocked.
REJECT
o Works like the DROP target, but will also return an error message to the
host sending the packet that the packet was blocked
--reject-with qualifierQualifier is an ICMP message
LOG
o The packet information is sent to the syslog daemon for logging.
o iptables continues processing with the next rule in the table.
o You can't log and drop at the same time ->use two rules.
--log-prefix ”reason"
SNAT
o Used to do source network address translation rewriting the source IP
address of the packet
o The source IP address is user defined
--to-source <address>[-<address>][:<port>-<port>]
DNAT
o Used to do destination network address translation. ie. rewriting the
destination IP address of the packet
--to-destination ipaddress
MASQUERADE
o Used to do Source Network Address Translation.
o By default the source IP address is the same as that used by the firewall's
interface
[--to-ports <port>[-<port>]]
6
04/11/2022
S
S
S
D
d
04/11/2022 13
7
04/11/2022
8
04/11/2022
Deny ping
iptables -A OUTPUT -p icmp --icmp-type -j REJECT
iptables -A INPUT -p icmp --icmp-type -j DROP
Allow ping request and reply
o iptables is being configured to allow the firewall to send ICMP echo-
requests (pings) and in turn, accept the expected ICMP echo-replies.
iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
o If more than 5 SYN packets per second, the packets are dropped.
o If source/destination sence dropped packets, it will resend three
times
o If drops continue after 3 reset packets, source will reduce packet
speed.
9
04/11/2022
10
04/11/2022
http request
Ping
http reply
Ex:
Out: iptables -A OUTPUT -p icmp -j REJECT (DROP)
In: iptables -A INPUT -p icmp -j REJECT (DROP)
11
04/11/2022
Server
(forward)
PC PC
(source) (destination)
04/11/2022 23
12