+iptables-cn (2:1.4.2-1) stable; urgency=low
+
+ * Upgrade paketa za Lenny
+ * Gasi se SSH bruteforce zastita ako je aktivan Fail2Ban servis
+
+ -- Dinko Korunic <kreator@carnet.hr> Tue, 14 Apr 2009 19:26:20 +0200
+
iptables-cn (2:1.2.11-6) stable; urgency=low
* ne izadji s greskom u slucaju da se SSH bruteforce zastita ne uspije
Source: iptables-cn
Section: net
Priority: optional
-Maintainer: Dinko Korunic <kreator@carnet.hr>
+Maintainer: Dinko Korunic <kreator@CARNet.hr>
Build-Depends: debhelper (>= 4)
Standards-Version: 3.7.2
Package: iptables-cn
Architecture: all
-Depends: iptables (>= 1.2.11-10)
+Depends: iptables (>= 1.4.2-6)
Conflicts: iptables-cn (<< 2:1.2.11-4)
Description: Linux kernel 2.4+ iptables administration tools
netfilter and iptables provide a Linux kernel framework for
mv /etc/default/iptables /etc/default/iptables-cn
fi
-# check if there is any default netfilter policy and install default SSH
-# REJECT recent if there is none..
-# also, save current set of rules into active and inactive configuration
-if [ ! -e /var/lib/iptables/active ]; then
- if ! iptables-save | grep '^-' >/dev/null; then
- echo "CN: Netfilter rules empty: importing SSH bruteforce rules"
- /usr/share/doc/iptables-cn/examples/ssh-bruteforce \
- 1>/dev/null 2>&1 || true
- fi
+# check to see if fail2ban is installed
+check=(fail2ban fail2ban-cn)
+check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
+if [ "x$check" != "x" ]; then
+ echo "CN: Detected Fail2Ban installation, will remove SSH bruteforce rules by default"
+ iptables -D SSH_Brute_Force -m recent ! --rcheck --seconds 90 \
+ --hitcount 3 --name SSH --rsource \
+ -j RETURN >/dev/null 2>&1 || true
+ iptables -D SSH_Brute_Force -p tcp -j REJECT \
+ --reject-with icmp-port-unreachable >/dev/null 2>&1 || true
+ iptables -D INPUT -p tcp -m tcp --dport 22 -m state \
+ --state NEW -m recent --set --name SSH --rsource \
+ -j SSH_Brute_Force >/dev/null 2>&1 || true
+ iptables -X SSH_Brute_Force >/dev/null 2>&1 || true
+
echo "CN: Saving current Netfilter rules to /var/lib/iptables/active"
iptables-save > /var/lib/iptables/active
+else
+ # check if there is any default netfilter policy and install default SSH
+ # REJECT recent if there is none..
+ # also, save current set of rules into active and inactive configuration
+ if [ ! -e /var/lib/iptables/active ]; then
+ if ! iptables-save | grep '^-' >/dev/null; then
+ echo "CN: Netfilter rules empty: importing SSH bruteforce rules"
+ /usr/share/doc/iptables-cn/examples/ssh-bruteforce \
+ 1>/dev/null 2>&1 || true
+ fi
+ echo "CN: Saving current Netfilter rules to /var/lib/iptables/active"
+ iptables-save > /var/lib/iptables/active
+ fi
fi
# create inactive