Iptables

From DarkWiki
Revision as of 07:35, 24 January 2017 by Apowney (talk | contribs) (Block entire subnets)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Block SSH brute force attacks

With logging:

iptables -N LOGDROP
iptables -A LOGDROP -j LOG
iptables -A LOGDROP -j DROP
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent  --update --seconds 60 --hitcount 5 -j LOGDROP

Without logging:

iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent  --update --seconds 60 --hitcount 5 -j DROP

Block entire subnets

iptables -A INPUT -s 58.218.0.0/16 -j DROP

Block specific IP address

iptables -A INPUT -s 12.23.34.45 -j DROP