Re: iptables and ssh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

LC schrieb:
Hi,

How do write the code for iptables to drop IP(s) trying to access ssh after 3 tries and block it for 10mins?

regards

sth like this?
this is from my iptables script, you have to adjust the variables.

$ipt -A INPUT -m state --state NEW -p tcp --dport 22 -m recent --name SSH --update --seconds 60 --hitcount 4 -j LOG_DROP

$ipt -A INPUT -m state --state NEW -p tcp --dport 22 -m recent --name SSH --set


My exisiting script is created by webmin, it is as follows. How do i include the above to this exisiting one?

# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:FORWARD ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -d 224.0.0.251 --dport 5353 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 21 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 22 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 25 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 53 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --sport 53 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state -m tcp --dport 80 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 110 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 443 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 993 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 995 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 1012 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 1500 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 6277 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --sport 6277 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 4455 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 5100 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6000 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6001 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6002 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6003 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6004 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6005 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6006 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6007 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6008 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6009 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6010 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6969 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 8000 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 8001 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 8080 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 20000 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6666 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6667 --state NEW -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp -m state --dport 6668 --state NEW -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Generated by webmin
*mangle
:FORWARD ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed
# Generated by webmin
*nat
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed
--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux