I use a simple iptables ruleset + sshguard to protect my linode. Firewall UI's are nice, but overkill for a linode IMHO.
To generate a simple iptables ruleset, you can use any number of the available Web generators. I really like this one:
http://www.lowth.com/LinWiz/
Once you have your ruleset, just active with:
Code:
iptables-restore < /path/to/ruleset
Now that you have a firewall blocking everything but ssh, http, whatever, add sshguard:
http://sshguard.sourceforge.net/I use Gentoo, so it was a simple matter of:
Code:
echo "app-admin/sshguard ~x86" >> /etc/portage/package.keywords
emerge sshguard
Once you have the binary installed, adjust syslog-ng.conf (or use the tail method). Again, on Gentoo, it's simply adding this to /etc/syslog-ng/syslog-ng.conf:
Code:
destination sshguardproc {
program("/usr/sbin/sshguard"
template("$DATE $FULLHOST $MESSAGE\n"));
};
filter f_sshlogs { facility(auth, authpriv) and match("sshd"); }; # for sshguard
log { source(src); filter(f_sshlogs); destination(sshguardproc); };
Final step is to add sshguard chain and rule to your iptables ruleset, then importing with iptables-restore.
Here's my ruleset, for example:
Code:
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:sshguard - [0:0]
:REJECT-PKT - [0:0]
:SYN-FLOOD - [0:0]
######################################################################
# Allow all loopback interface traffic
-A INPUT -i lo -j ACCEPT
# Block all attempts to spoof the loopback address
-A INPUT -s 127.0.0.0/8 -j DROP
-A INPUT -d 127.0.0.0/8 -j DROP
# Block all attempts to spoof the local IP address
-A INPUT -s 64.22.124.206 -j DROP
# Block Syn Flood attacks
-A INPUT -p tcp -m tcp --syn -j SYN-FLOOD
# Ensure that TCP connections start with syn packets
-A INPUT -p tcp -m tcp ! --syn -m state --state NEW -j DROP
# Allow session continuation traffic
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
# Pass ssh traffic to sshguard for processing
-A INPUT -p tcp -m tcp --dport 22 -j sshguard
# Allow selected TCP/IP and/or UDP services
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
# Block all other TCP/IP and UDP traffic
-A INPUT -j REJECT-PKT
######################################################################
# Syn flood filtering chain
-A SYN-FLOOD -m limit --limit 1/s --limit-burst 4 -j RETURN
-A SYN-FLOOD -j DROP
######################################################################
# Chain used to reject all TCP/IP, UDP and ICMP/PING packets
-A REJECT-PKT -p tcp -m tcp -j REJECT --reject-with tcp-reset
-A REJECT-PKT -p udp -m udp -j REJECT --reject-with icmp-port-unreachable
-A REJECT-PKT -p icmp -m icmp --icmp-type ping -j REJECT --reject-with icmp-host-unreachable
COMMIT
(With exception for my own tweaking, credit for this ruleset goes to
http://www.lowth.com/LinWiz/)