Show Menu
Cheatography

iptables Cheat Sheet (DRAFT) by

All the imported flags & arguments you need to configure your firewall with iptables. Also a small list of common ports & protocols.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Ports

Protocol
Descri­ption
Port
TCP/UDP
FTP
File Transfer Protocol
20,21
TCP
SSH
Secure Shell
22
TCP
SMTP
Simple Mail Transfer Protocol
25
TCP
HTTP
Hypertext Transfer Protocol
80
TCP
DNS
Domain Name System
53
TCP/UDP
DHCP
Dynamic Host Config­uration Protocol
67,68
UDP
OSPF
Open Shortest Path First
89
IP
POP3
Post Office Protocol version 3
110
TCP
NTP
Network Time Protocol
123
UDP
IMAP
Internet Message Access Protocol
143
TCP
BGP
Border Gateway Protocol
179
TCP
IS-IS
Interm­ediate System to Interm­ediate System
149
IP
SNMP
Simple Network Management Protocol
161
UDP
HTTPS
HTTP Secure
443
TCP
SMB
Server Message Block
445
TCP/UDP
L2TP
Layer 2 Tunneling Protocol
1701
UDP
PPTP
Point-­to-­Point Tunneling Protocol
1723
TCP
RTMP
Real Time Messaging Protocol
1935
UDP
NFS
Network File System
2049
TCP/UDP
RDP
Remote Desktop Protocol
3389
TCP/UDP
SIP
Session Initiation Protocol
5060
UDP/TCP
IGMP
Internet Group Management Protocol
N/A
IP
RTP
Real-time Transport Protocol
N/A
UDP
 

Basic Commands

Descri­ption
Descri­ption
Insert
iptables -I <ch­ain> [rule-­number] [selec­tion]
Replace
iptables -R <ch­ain> <ru­le-­num­ber>
Delete
iptables -D
Append
iptables -A
List
iptables -L
Policy (Set policy)
iptables -P <ch­ain> <po­lic­y>
Zero (Reset Counters in Chain)
iptables -Z [chain [rule]]
Flush (Delete all rules in chain)
iptables -F [chain]
New (Create user-d­efined chain)
iptables -N <ch­ain­-na­me>
Rename (Rename user-d­efined chain)
iptables -R <ch­ain> <ne­w-c­hai­n-n­ame>
Help
iptables -h
[Optional Parame­ter]; <Re­quired Parame­ter­>; "­sel­ect­ion­" is composed of one or more package selectors

Selectors

Descri­ption
Selector
Values
Protocol
-p <pr­oto­col>
tcp/ud­p/icmp
Src Address
-s <ip4 addres­s[/­Mas­k]>
Source IP4 Address
Dest Address
-d <ip4 addres­s[/­Mas­k]>
Destin­ation IP4 Address
Network Interace
-i <In­ter­fac­e>
(e.g. eth0, wildcard: +)
Src Port
--sport
Source Port
Dest
--dport
Destin­ation Port
Goto
-g <ch­ain>
Chain name
Jump
-j <ta­rge­t>
ACCEPT, DROP, REJECT