Académique Documents
Professionnel Documents
Culture Documents
Blair Hicks
blair@unixquest.com
Iptables Firewalls
Introduction
NAT
Applications
Optimization
Packet Filtering
Packet Traversal
User-defined
iptables commands
Resources
iptables Syntax
What is a Firewall?
Firewall Programs
Ipfwadm :
Ipchains :
Iptables
Firewall Options
Linux
Sneaker Net
Applications
Volatile environments
Internal Security
System Segregation
TCP Header
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| IHL |Type of Service|
Total Length
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
Identification
|Flags|
Fragment Offset
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Time to Live |
Protocol
|
Header Checksum
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
Source Address
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
Destination Address
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port
|
Destination Port
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
Sequence Number
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
Acknowledgment Number
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
| Control
|
|
Input
Chain
Routing
Deny
Local
Processes
Forward
Chain
Output
Chain
Deny
Deny
Forward
Chain
Deny
Input
Chain
Deny
Local
Processes
Output
Chain
Deny
iptables --flush
iptables Targets
ACCEPT
DROP
QUEUE
RETURN
iptables syntax
Forwarding Packets
iptables -A FORWARD -i <internal interface> \
-o <external interface> -s 192.168.56.1/32 --sport \
1024:65535 -m state --state \ NEW,ESTABLISHED,RELATED
-j ACCEPT
iptables -L -v -n
Chain
pkts
3300
140
378K
140
304
INPUT
bytes
136K
51297
46M
10220
35676
Chain
pkts
4435
4717
13
4379
4609
9
40
Chain
pkts
5687
102
78904
140
source
0.0.0.0/0
0.0.0.0/0
0.0.0.0/0
0.0.0.0/0
0.0.0.0/0
0.0.0.0/0
0.0.0.0/0
destination
192.168.56.2
0.0.0.0/0
0.0.0.0/0
0.0.0.0/0
0.0.0.0/0
destination
0.0.0.0/0
0.0.0.0/0
192.168.56.1
0.0.0.0/0
0.0.0.0/0
10.10.90.10
192.168.56.10
destination
192.168.56.1
0.0.0.0/0
0.0.0.0/0
0.0.0.0/0
tcp dpt:22
LOG flags 0 level 4
LOG flags 0 level 4
LOG flags 0 level 4
tcp spt:22
LOG flags 0 level 4
LOG flags 0 level 4
LOG
--log-level
--log-prefix
--log-tcp-sequence
--log-tcp-options
--log-ip-options
log_analysis output
3
4
4
4
3
3
4
4
4
4
3
3
3
3
3
3
3
3
3
4
4
3
3
3
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
Chain: input
NAT Overview
Source NAT
Destination NAT
Advanced DNAT
Port Redirection:
iptables -t nat -A PREROUTING -i <external interface> \
-p tcp --sport 1024:65535 -d <external address> --dport 80 \
-j DNAT --to-destination <local server>:81
Server Farms:
iptables -t nat -A PREROUTING -i <external interface> \
-p tcp --sport 1024:65535 -d <external WEB address> \
--dport 80 -j DNAT \
--to-destination 192.168.56.10-192.168.56.15
Firewall Optimization