Dank u wel voor de link!
IK heb nu het volgende geschreven met hulp van online forums. Het is lang nog niet klaar, maar biedt
nu wel de basis functionaliteit die de meeste en meeste mensen nodig hebben:
#! /bin/bash
# Flush chains en delete non-standaard chains. Omdat er anders dubbele regels in de firewall komen.
iptables -F
iptables -X
# Drop well known port scans
iptables -A INPUT -p tcp --tcp-flag ALL NONE -j DROP
iptables -A INPUT -p tcp --tcp-flag ALL ALL -j DROP
iptables -A INPUT -p tcp --tcp-flag SYN,FIN SYN,FIN -j DROP
# Allow HTTP traffic
iptables -A INPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --sport 80 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
# Allow DNS traffic
iptables -A INPUT -p udp --sport 53 -m state --state ESTABLISHED,RELATED -j ACCEPT
#iptables -A OUTPUT -p tcp --dport 53 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
# Allow FTP @ port 21
iptables -A INPUT -p tcp --sport 21 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --dport 21 -m state --state NEW,ESTABLISHED -j ACCEPT
# Allow Passive FTP connection
iptables -A INPUT -p tcp --sport 1024: --dport 1024: -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 1024: --dport 1024: -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow Pop / SMTP traffic
iptables -A INPUT -p tcp --sport 110 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --dport 110 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --sport 25 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --dport 25 -m state --state NEW,ESTABLISHED -j ACCEPT
# Allow https traffic
iptables -A INPUT -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
# Allow Local communication
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
# Policy: Drop any remaining traffic that is not defined in my allow list.
iptables -A INPUT -j DROP
iptables -A FORWARD -j DROP
iptables -A OUTPUT -j DROP
# Laat de inhoud van iptables zien, nadat de script gelopen heeft. Check of alles goed is ingevoerd.
iptables -n -L
Mocht iemand betere regels hebben, vertel!