Many of us are constantly plagued with port knocking and script kiddies from places like the Amazon Cloud. With security issues, the procedural recommended post encroachment steps per CERT are: 1) Remove the computer from your network (probably not workable if this is a server) [use IPtables to protect it initially] 2) Gather log information about specific times, ports and ip addresses (both source and destination) 3) Report to the SWIP authorities including the correct time zones for each exploit. 4) Optional - load BackTrack and run forensics on the system if you CAN reboot it. 5) Optional - setup a honeypot trap for the users including network alerting and logging. Using IPtables: Generally, since you can't always drop large numbers of IPADDRESSES into your IPtables & the script kiddies just DHCP a new source address, so this is a temporary measure. First drop in a basicIP table - here's a good basic example (season to taste): [Do this while sitting in front of the machine so you don't accidently shut yourself out] You going to need iptables (you should have it already): # dpkg -l iptables iptables 1.2.11-10 Linux kernel 2.4+ iptables administration to # rpm -qa | grep iptablesiptables-xxxxx Check to see if it's there: # which iptables /sbin/iptables If the utility is missing you can install it like so: APT # apt-get update && apt-get install iptables RPM # rpm -Uvh iptables-xxxx.rpm Preparing ################################# [100%] NEXT: Drop in a basic configuration: # /etc/init.d/iptables start Cut and copy this basic table example to /root/iptables/iptables.first This example only allows port 22, 80 and 443 and does some time based allow log and drop (which might break if you have extensive scp jobs) (season to taste - for instance if you need another port add it; or you have eth1 change this). # Generated by iptables-save on Sun Oct 19 23 05:32:09 2008 *filter :INPUT ACCEPT [273:55355] :FORWARD ACCEPT [0:0] :LOGNDROP - [0:0] :OUTPUT ACCEPT [92376:20668252] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -i eth0 -p tcp -m tcp --dport 22 -j ACCEPT -A INPUT -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT -A INPUT -i eth0 -p tcp -m tcp --dport 443 -j ACCEPT -A INPUT -i lo -j ACCEPT # Optional log and drop limits -A INPUT -j LOGNDROP -A LOGNDROP -p tcp -m limit --limit 5/min -j LOG --log-prefix "Denied TCP: " --log-level 7 -A LOGNDROP -p udp -m limit --limit 5/min -j LOG --log-prefix "Denied UDP: " --log-level 7 -A LOGNDROP -p icmp -m limit --limit 5/min -j LOG --log-prefix "Denied ICMP: " --log-level 7 -A LOGNDROP -j DROP COMMIT # Completed on Sun Oct 19 05:32:09 2008Next import it: # /sbin/iptables-restore /root/iptables/iptables.last You can hand edit this with vi or joe # /sbin/iptables-restore