week13-FIREWALL IPTABLES
week13-FIREWALL IPTABLES
week13-FIREWALL IPTABLES
1
Firewall
Firewall
IP
IPTables
Tables
2
32-4 FIREWALLS
4
What Is Firewall?
5
Figure 32.22 Firewall
6
Types of Firewalls
Packet Filters
7
There is a Packet
Filter in the front
8
Packet Filters
9
Note
10
Packet Filters
simplest of components
foundation of any firewall system
examine each IP packet (no context) and permit or deny according to rules
hence restrict access to services (ports)
possible default policies
that not expressly permitted is prohibited
that not expressly prohibited is permitted
11
Packet-filter firewall
12
Packet Filters
13
Attacks on Packet Filters
IP address spoofing
fake source address to be trusted
add filters on router to block
source routing attacks
attacker sets a route other than default
block source routed packets
tiny fragment attacks
split header info over several tiny packets
either discard or reassemble before check
14
IP Table Stateful Packet Filters
15
Question - 1
16
Question - 1
Answer:
17
What is a proxy
honey?
18
Application Level Gateway (or Proxy)
19
Note
20
Proxy firewall
21
Proxy Firewall
22
Firewalls - Application Level Gateway (or Proxy)
23
Question - 2
24
Question - 2
Answer:
25
Question - 3
26
Question - 3
Answer:
27
Firewalls - Circuit Level Gateway
28
Firewalls - Circuit Level Gateway
29
Circuit Level Gateway
30
Question - 4
Answer:
31
Question - 5
32
Question - 5
Answer:
NAT hides the addresses of devices behind the NAT device and
prevents attacks that use knowledge of internal network
addresses behind the NAT device. Some firewall policies, such as
allowing traffic to high-numbered ports only if there was a
matching outgoing request, require port numbers and internal
addresses. This is easier to determine the firewall also knows the
NAT translation table.
33
Question - 6
6. In a distributed firewall, an administrator ships out firewall rules to
hosts over an authenticated channel, and each host enforces its
own policy. Give one advantage and one disadvantage of a
distributed firewall, in comparison with a centralized firewall.
34
Question - 6
6. In a distributed firewall, an administrator ships out firewall rules to
hosts over an authenticated channel, and each host enforces its
own policy. Give one advantage and one disadvantage of a
distributed firewall, in comparison with a centralized firewall.
Answer:
IP
IPTables
Tables
36
37
What is netfilter/iptables?
38
Packet Processing in IP Tables
There are three tables in total. The first is the mangle table which is
responsible for the alteration of quality of service bits in the TCP
header. This is hardly used in a home or SOHO environment.
The second table is the filter queue which is responsible for packet
filtering. It has three built-in chains in which you can place your
firewall policy rules.
The third table is the nat queue which is responsible for network
address translation. It has two built-in chain
39
Processing For Packets Routed By The Firewall 1/2
You need to specify the table and the chain for each firewall rule you
create. There is an exception: Most rules are related to filtering, so
iptables assumes that any chain that's defined without an associated
table will be a part of the filter table. The filter table is therefore the
default.
40
Processing For Packets Routed By The Firewall 1/2
41
Processing For Packets Routed By The Firewall 2/2
To help understand iptables, take a look at the way packets are handled by
iptables. In figure a TCP packet from the Internet arrives at the firewall's
interface on Network A to create a data connection.
The packet is first examined by your rules in the mangle table's PREROUTING
chain, if any. It is then inspected by the rules in the nat table's PREROUTING
chain to see whether the packet requires DNAT. It is then routed.
If the packet is destined for a protected network, then it is filtered by the rules in
the FORWARD chain of the filter table and, if necessary, the packet undergoes
SNAT before arriving at Network B. When the destination server decides to
reply, the packet undergoes the same sequence of steps.
If the packet is destined for the firewall itself, then it is filtered by the rules in the
INPUT chain of the filter table before being processed by the intended
application on the firewall. At some point, the firewall needs to reply. This reply
is inspected by your rules in the OUTPUT chain of the mangle table, if any. The
rules in the OUTPUT chain of the nat table determine whether address
translation is required and the rules in the OUTPUT chain of the filter table are
then inspected before the packet is routed back to the Internet.
42
Targets & Jumps
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
iptables stops further processing.
The packet is handed over to the end application or the operating system for
processing
DROP
iptables stops further processing.
The packet is blocked.
LOG
The packet information is sent to the syslog daemon for logging.
iptables continues processing with the next rule in the table.
You can't log and drop at the same time ->use two rules.
--log-prefix ”reason"
REJECT
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 qualifier Qualifier is an ICMP message 43
Targets & Jumps
SNAT
Used to do source network address translation rewriting the source IP
address of the packet
The source IP address is user defined
--to-source <address>[-<address>][:<port>-<port>]
DNAT
Used to do destination network address translation. ie. rewriting the
destination IP address of the packet
--to-destination ipaddress
MASQUERADE
Used to do Source Network Address Translation.
By default the source IP address is the same as that used by the firewall's
interface
[--to-ports <port>[-<port>]]
44
Important Iptables Command Switch Operations
Each line of an iptables script not only has a jump, but they also have
a number of command line options that are used to append rules to
chains that match your defined packet characteristics, such the
source IP address and TCP port. There are also options that can be
used to just clear a chain so you can start all over again.
45
Important Iptables Command Switch Operations
46
Common TCP and UDP Match Criteria
47
Common TCP and UDP Match Criteria
Example:
iptables -A FORWARD -s 0/0 -i eth0 -d 192.168.1.58 -o eth1 -p TCP \
--sport 1024:65535 --dport 80 -j ACCEPT
48
Defense for SYN flood attacks
If more than 5 SYN packets per second, the packets are dropped.
If source/destination sence dropped packets, it will resend three times
If drops continue after 3 reset packets, source will reduce packet speed.
49
Saving Your iptables Scripts
Fedora comes with a program called lokkit that you can use to generate a very
rudimentary firewall rule set. It prompts for the level of security and then gives you the
option of doing simple customizations. It is a good place for beginners to start on a
test system so that they can see a general rule structure.
Like the service iptables save command, lokkit saves the firewall rules in a
new /etc/sysconfig/iptables file for use on the next reboot.
Once you have become familiar with the iptables syntax, it's best to write scripts
that you can comment and then save it to /etc/sysconfig/iptables. It makes
them much more manageable and readable.
50
Loading Kernel Modules Needed By iptables
The iptables application requires you to load certain kernel modules to activate
some of its functions. Whenever any type of NAT is required, the iptable_nat
module needs to be loaded. The ip_conntrack_ftp module needs to be added for
FTP support and should always be loaded with the ip_conntrack module which
tracks TCP connection states. As most scripts probably will keep track of connection
states, the ip_conntrack module will be needed in any case. The ip_nat_ftp
module also needs to be loaded for FTP servers behind a NAT firewall.
52
Summary
have considered:
firewalls
types of firewalls
IP Tables
53
How Do You Want Protect Your Network System
Thank You
54