C
C:S
Foren As
Moin,
also habe die Tage die Logfiles meines debian-etch-Root-servers mal näher studiert, und doch ziemlich viele dfind scans, ssh Angriffe und dergleichen gefunden. Daher habei ich den ssh-port mal von 22 weg bewegt, und mir mein iptables-skript nochmal angeschaut und leicht verändert.
Ich wollte euch jetzt mal bitten einen Blick auf das Skript zu werfen, und mir eure Verbesserungsvorschläge zu schreiben, bin für alle Tipps dankbar!
Der Root Server ist auf mehreren IPs ansprechbar (eine Hauptip + Subnetzwerk). Wird von 3 Personen genutzt, jede hat ihre eigene Ip, und Webserver und Mailzugang. Auf einer ip läuft noch ein Teamspeak-Server.
Hier noch was iptables -L ausspuckt:
Schomal Danke fürs Drüberschaun,
Gruß, CS
also habe die Tage die Logfiles meines debian-etch-Root-servers mal näher studiert, und doch ziemlich viele dfind scans, ssh Angriffe und dergleichen gefunden. Daher habei ich den ssh-port mal von 22 weg bewegt, und mir mein iptables-skript nochmal angeschaut und leicht verändert.
Ich wollte euch jetzt mal bitten einen Blick auf das Skript zu werfen, und mir eure Verbesserungsvorschläge zu schreiben, bin für alle Tipps dankbar!
Der Root Server ist auf mehreren IPs ansprechbar (eine Hauptip + Subnetzwerk). Wird von 3 Personen genutzt, jede hat ihre eigene Ip, und Webserver und Mailzugang. Auf einer ip läuft noch ein Teamspeak-Server.
Code:
#!/bin/bash
# Skript /etc/network/if-pre-up.d/iptables-up fuer Debian
IPTABLES=/sbin/iptables
#Mal durchspülen...
$IPTABLES -F
$IPTABLES -t mangle -F
# Setzen der Default-Policies
$IPTABLES -P INPUT DROP
$IPTABLES -P FORWARD DROP
$IPTABLES -P OUTPUT DROP
# Kette, in die zu blockende IPs reinkommen
$IPTABLES -F blockips
$IPTABLES -X blockips
$IPTABLES -N blockips
$IPTABLES -A INPUT -j blockips
$IPTABLES -A OUTPUT -j blockips
#Ungültige Pakete verwerfen
$IPTABLES -A INPUT -m state --state INVALID -j DROP
#Bestehende Verbindungen erlauben
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#HTTP
$IPTABLES -A INPUT -p tcp --dport 80 -j ACCEPT
$IPTABLES -A OUTPUT -p tcp --sport 80 -j ACCEPT
#HTTPS
$IPTABLES -A INPUT -p tcp --dport 443 -j ACCEPT
$IPTABLES -A OUTPUT -p tcp --sport 443 -j ACCEPT
#SMTP
$IPTABLES -A INPUT -p tcp --dport 25 -j ACCEPT
$IPTABLES -A OUTPUT -p tcp --sport 25 -j ACCEPT
#SSH
$IPTABLES -A INPUT -p tcp --dport 2222 -j ACCEPT
$IPTABLES -A OUTPUT -p tcp --sport 2222 -j ACCEPT
#FTP (nur für apt-get)
$IPTABLES -A OUTPUT -p tcp --dport 20:21 -j ACCEPT
$IPTABLES -A OUTPUT -p tcp --sport 1024:65535 -j ACCEPT
#IMAPS
$IPTABLES -A INPUT -p tcp --dport 993 -j ACCEPT
$IPTABLES -A OUTPUT -p tcp --sport 993 -j ACCEPT
#POP3S
$IPTABLES -A INPUT -p tcp --dport 995 -j ACCEPT
$IPTABLES -A OUTPUT -p tcp --sport 995 -j ACCEPT
#TEAMSPEAK (soll nur auf einer IP erreichbar sein)
$IPTABLES -A INPUT -p tcp --dport 14534 -d ***.***.***.*** -j ACCEPT
$IPTABLES -A INPUT -p udp --dport 8767:8770 -d ***.***.***.*** -j ACCEPT
$IPTABLES -A OUTPUT -p tcp --sport 14534 -s ***.***.***.*** -j ACCEPT
$IPTABLES -A OUTPUT -p udp --sport 8767:8770 -s ***.***.***.*** -j ACCEPT
#loopback
$IPTABLES -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
$IPTABLES -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
#Ping
$IPTABLES -A INPUT -p icmp --icmp-type 8 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 8 -j ACCEPT
$IPTABLES -A OUTPUT -p icmp --icmp-type 0 -j ACCEPT
#DNS
$IPTABLES -A INPUT -p udp --sport 53 -j ACCEPT
$IPTABLES -A OUTPUT -p udp --dport 53 -j ACCEPT
#NMAP-Scans verhindern
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags ALL FIN,URG,PSH -j LOG --log-prefix "NMAP-XMAS SCAN:" --log-tcp-options --log-ip-options --log-level debug
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags ALL NONE -j LOG --log-prefix "NMAP-NULL SCAN:" --log-tcp-options --log-ip-options --log-level debug
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags ALL NONE -j DROP
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags SYN,RST SYN,RST -j LOG --log-prefix "SYN/RST SCAN:" --log-tcp-options --log-ip-options --log-level debug
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags SYN,FIN SYN,FIN -j LOG --log-prefix "SYN/FIN SCAN:" --log-tcp-options --log-ip-options --log-level debug
$IPTABLES -t mangle -A PREROUTING -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
#zu blockende IPs werden geladen (Kette 'blockips')
#momentan scannt das Script hier nur den apache-error log durch und liest alle ips von diversen dfind scans ein, um diese dann zu sperren
/opt/firewall/refreships.sh
Hier noch was iptables -L ausspuckt:
Code:
Chain INPUT (policy DROP)
target prot opt source destination
blockips all -- anywhere anywhere
DROP all -- anywhere anywhere state INVALID
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere tcp dpt:www
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp
ACCEPT tcp -- anywhere anywhere tcp dpt:2222
ACCEPT tcp -- anywhere anywhere tcp dpt:imaps
ACCEPT tcp -- anywhere anywhere tcp dpt:pop3s
ACCEPT tcp -- anywhere [HOST].[SERVER_SUB_IP] tcp dpt:14534
ACCEPT udp -- anywhere [HOST].[SERVER_SUB_IP] udp dpts:8767:8770
ACCEPT all -- localhost localhost
ACCEPT icmp -- anywhere anywhere icmp echo-request
ACCEPT udp -- anywhere anywhere udp spt:domain
Chain FORWARD (policy DROP)
target prot opt source destination
Chain OUTPUT (policy DROP)
target prot opt source destination
blockips all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp spt:www
ACCEPT tcp -- anywhere anywhere tcp spt:https
ACCEPT tcp -- anywhere anywhere tcp spt:smtp
ACCEPT tcp -- anywhere anywhere tcp spt:2222
ACCEPT tcp -- anywhere anywhere tcp dpts:ftp-data:ftp
ACCEPT tcp -- anywhere anywhere tcp spts:1024:65535
ACCEPT tcp -- anywhere anywhere tcp spt:imaps
ACCEPT tcp -- anywhere anywhere tcp spt:pop3s
ACCEPT tcp -- [HOST].[SERVER_SUB_IP] anywhere tcp spt:14534
ACCEPT udp -- [HOST].[SERVER_SUB_IP] anywhere udp spts:8767:8770
ACCEPT all -- localhost localhost
ACCEPT icmp -- anywhere anywhere icmp echo-request
ACCEPT icmp -- anywhere anywhere icmp echo-reply
ACCEPT udp -- anywhere anywhere udp dpt:domain
Chain blockips (2 references)
target prot opt source destination
DROP all -- 195.153.113.140 anywhere
DROP all -- graphics.djmixed.com anywhere
DROP all -- pd9569fb3.dip0.t-ipconnect.de anywhere
DROP all -- 38107.vs.webtropia.com anywhere
DROP all -- wpc1409.amenworld.com anywhere
DROP all -- 64.32.4.250 anywhere
DROP all -- 66-221-254-44.static.propagation.net anywhere
DROP all -- ns.fx3767-dedic1.hosting-ie.com anywhere
DROP all -- s210.silver.fastwebserver.de anywhere
DROP all -- escr-motorsport.de anywhere
DROP all -- s15283345.onlinehome-server.info anywhere
DROP all -- aveva.ru anywhere
DROP all -- 91.139.170.170 anywhere
DROP all -- 92.48.106.120 anywhere
CS:~$ iptables -t mangle -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
LOG tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,PSH,URG LOG level debug tcp-options ip-options prefix `NMAP-XMAS SCAN:'
DROP tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,PSH,URG
LOG tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE LOG level debug tcp-options ip-options prefix `NMAP-NULL SCAN:'
DROP tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE
LOG tcp -- anywhere anywhere tcp flags:SYN,RST/SYN,RST LOG level debug tcp-options ip-options prefix `SYN/RST SCAN:'
DROP tcp -- anywhere anywhere tcp flags:SYN,RST/SYN,RST
LOG tcp -- anywhere anywhere tcp flags:FIN,SYN/FIN,SYN LOG level debug tcp-options ip-options prefix `SYN/FIN SCAN:'
DROP tcp -- anywhere anywhere tcp flags:FIN,SYN/FIN,SYN
Schomal Danke fürs Drüberschaun,
Gruß, CS