Serwer będzie za routerem, a na świat przekierowany tylko port SSH tak aby z poza domu, w razie czego, w bezpieczny sposób dostać się do plików.
Posłużyłem się gotowcem dla początkujących http://pl.wikibooks.org/wiki/Debian_-_u ... e_iptables zmieniłem tyllko OUTPUT na ACCEPT i dodałem swoje reguły/porty i tutaj właśnie nie rozumiem...
Na początku dałem tak:
Kod: Zaznacz cały
[color=#000000][font=monospace]iptables [/font][/color][color=#660033][font=monospace]-P[/font][/color][color=#000000][font=monospace] INPUT DROP[/font][/color]
iptables [color=#660033]-P[/color] FORWARD DROP
[color=#000000][font=monospace]iptables [/font][/color][color=#660033][font=monospace]-P[/font][/color][color=#000000][font=monospace] OUTPUT DROP[/font][/color]

Poniżej całość, proszę o ocenę czy dobrze to poskładałem w całość:
Kod: Zaznacz cały
#!/bin/bash
### BEGIN INIT INFO
# Provides: firewall.sh
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
# CZYSZCZENIE STARYCH REGUŁ
iptables -F
iptables -X
iptables -F -t nat
iptables -X -t nat
iptables -F -t filter
iptables -X -t filter
# USTAWIENIE POLITYKI DZIAŁANIA
iptables -P INPUT ACCEPT
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-request -j REJECT --reject-with icmp-host-unreachable
# OCHRONA PRZED SKANOWANIEM ACK SCAN
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH ACK -j LOG --log-prefix "ACK scan: "
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH ACK -j DROP # Metoda ACK (nmap -sA)
#OCHRONA PRZED SKANOWANIEM FIN SCAN
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH FIN -j LOG --log-prefix "FIN scan: "
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH FIN -j DROP # Skanowanie FIN (nmap -sF)
#OCHRONA PRZED SKANOWANIEM XMAS TREE SCAN
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH PSH -j LOG --log-prefix "Xmas scan: "
iptables -A INPUT -m conntrack --ctstate NEW -p tcp --tcp-flags SYN,RST,ACK,FIN,URG,PSH FIN,URG,PSH -j DROP # Metoda Xmas Tree (nmap -sX)
#OCHRONA PRZED SKANOWANIEM NULL SCAN
iptables -A INPUT -m conntrack --ctstate INVALID -p tcp ! --tcp-flags SYN,RST,ACK,FIN,PSH,URG SYN,RST,ACK,FIN,PSH,URG -j LOG --log-prefix "Null scan: "
#OCHRONA PRZED ATAKIEM Dos
iptables -A INPUT -m conntrack --ctstate INVALID -p tcp ! --tcp-flags SYN,RST,ACK,FIN,PSH,URG SYN,RST
iptables -N syn-flood
iptables -A INPUT -p tcp --syn -j syn-flood
iptables -A syn-flood -m limit --limit 1/s --limit-burst 4 -j RETURN
iptables -A syn-flood -m limit --limit 1/s --limit-burst 4 -j LOG --log-prefix "SYN-flood: "
iptables -A syn-flood -j DROP
# OCHRONA PRZED ATAKIEM PING OF DEATH
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j LOG --log-prefix "Ping: "
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT # Ping of death
# ZABLOKOWANIE PINGOWANIA
iptables -A INPUT -p icmp --icmp-type echo-request -j REJECT --reject-with icmp-host-unreachable
# BLOKOWANIE TELNETU
iptables -A OUTPUT -p tcp --dport telnet -j REJECT
iptables -A INPUT -p tcp --dport telnet -j REJECT
#Wpuszczanie
iptables -A INPUT -p tcp --dport 54555 -j ACCEPT #SSH
iptables -A INPUT -p udp --dport 54555 -j ACCEPT
iptables -A INPUT -p tcp --dport 137 -j ACCEPT #Samba
iptables -A INPUT -p udp --dport 137 -j ACCEPT
iptables -A INPUT -p tcp --dport 138 -j ACCEPT
iptables -A INPUT -p udp --dport 138 -j ACCEPT
iptables -A INPUT -p tcp --dport 139 -j ACCEPT
iptables -A INPUT -p udp --dport 139 -j ACCEPT
iptables -A INPUT -p tcp --dport 455 -j ACCEPT
iptables -A INPUT -p udp --dport 455 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT #Apache
iptables -A INPUT -p udp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 68 -j ACCEPT #DHCP
iptables -A INPUT -p udp --dport 68 -j ACCEPT
iptables -A INPUT -p tcp --dport 67 -j ACCEPT
iptables -A INPUT -p udp --dport 67 -j ACCEPT
#Wypuszczanie
iptables -A OUTPUT -p tcp --dport 54555 -j ACCEPT #SSH
iptables -A OUTPUT -p udp --dport 54555 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 137 -j ACCEPT #Samba
iptables -A OUTPUT -p udp --dport 137 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 138 -j ACCEPT
iptables -A OUTPUT -p udp --dport 138 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 139 -j ACCEPT
iptables -A OUTPUT -p udp --dport 139 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 455 -j ACCEPT
iptables -A OUTPUT -p udp --dport 455 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT #Apache
iptables -A OUTPUT -p udp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 68 -j ACCEPT #DHCP
iptables -A OUTPUT -p udp --dport 68 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 67 -j ACCEPT
iptables -A OUTPUT -p udp --dport 67 -j ACCEPT
#ZAPIS DO LOGA ODRZUCONYCH PAKIETÓW PRZYCHODZĄCYCH W KATALOGU var/log/messages
iptables -N LOGGING
iptables -A INPUT -j LOGGING
iptables -A LOGGING -m limit --limit 30/min -j LOG --log-prefix "IPTables-Dropped: " --log-level 4
iptables -A LOGGING -j DROP