• No results found

Netfilter. GNU/Linux Kernel version 2.4+ Setting up firewall to allow NIS and NFS traffic. January 2008

N/A
N/A
Protected

Academic year: 2021

Share "Netfilter. GNU/Linux Kernel version 2.4+ Setting up firewall to allow NIS and NFS traffic. January 2008"

Copied!
25
0
0

Loading.... (view fulltext now)

Full text

(1)

Netfilter

GNU/Linux Kernel version 2.4+

(2)
(3)

IP Packet Filtering Firewall

● iptables: is used to set up, maintain, and inspect 

the tables of IP packet filter rules in the Linux  Kernel

● Several different tables may be defined, they are: 

filter, nat and mangle table

filter, nat and mangle table

● Ecah  table contains a number of built­in chains 

and may also contain user­defined chain

(4)
(5)

Chains, rules and targets

● Each chain is a list of rules which can match a 

set of packets

● A firewall rule specifies criteria for a packet and 

target

● A target can be the name of a user­defined chain 

(6)
(7)
(8)

Tables and built­in chains

Filter Table's built­in chains:

● INPUT chain

(9)
(10)
(11)

Netfilter flowchart

Inbound

packets PREROUTINGMangle, nat Chain

Routing Decision

Mangle, filter

INPUT Chain ProcessLocal

Mangle, filter FORWARD Chain POSTROUTING Chain Outbound Packets

(12)
(13)
(14)
(15)
(16)
(17)

 Basic iptables syntax

iptables [­t tables] [options] chain [match] [target]

● iptables [-t table] [-ADC] chain rule-specification

[options]

● iptables [-t table] -I chain [rulenum] rule-specification

[options]

● iptables [-t table] -R chain rulenum rule-specification ● iptables [-t table] -D chain rulenum [options]

● iptables [-t table] -{LFZ] [chain] [options] ● iptables [-t table] -N chain

● iptables [-t table] -X [chain]

● iptables [-t table] -P chain target [options]

(18)

MAC match options

iptables [­t tables] [options] chain [match] [target]

Example:

iptables -A INPUT -m mac --mac-source 00:05:0A:1B:2D:3E -j ACCEPT

iptables -A INPUT -m mac –mac-source ! 00:05:0A:1B:2D:3E -j ACCEPT

(19)

Owner match options

Matching User ID, Group ID, or Process ID

Example:

(20)
(21)
(22)
(23)

open other dynamic ports

● Use similar script to capture the UDP and TCP 

ports for all the other daemon

● Use the appropriate iptables commands to open 

(24)
(25)

References

Related documents

How does an iptables based firewall decide as to which packets to subject to the INPUT chain of rules, which to the FORWARD chain of rules, and which to the OUTPUT chain of rules.

(Demo 3 in Section 18.2 inserted a new rule in the mangle table.) The mangle table has five rule chains: PREROUTING for alter- ing incoming packets before a routing decision is

# allow web and ftp traffic to the firewall iptables -A INPUT -i $INET_IF -p tcp \ --destination-port ftp -j ACCEPT iptables -A INPUT -i $INET_IF -p tcp \ --destination-port

Path of packets R R FORWARD POSTROUTING PREROUTING INPUT OUTPUT Routed through this system..

Table Operation Hook -t filter -A FORWARD PREROUTING INPUT FORWARD POSTROUTING OUTPUT Firefox SSHD ... Squid U ser K ern el. From where? What interfaces? Is that IP local to the FW

#modprobe ipt_tcpmss # Match tcpmss (a field in SYN packets that set maxsize) modprobe ipt_state # Match the current connection state. #modprobe ipt_unclean # Match

iptables –P OUTPUT –j ACCEPT iptables –P INPUT –j DROP. iptables –P FORWARD

IPTables Filter NAT Mangle Raw Incoming Packet Prerouting Prerouting Kernel Code Forward Postrouting Postrouting Send to HW Outgoing Packet Output Output Postrouting Output