i do have my a VPS (debian 7) with a public IP address and I would like to protect it. I would like to have access only to SSH (public/private keys), openVPN, services that are requested from the VPS itself, such as sending emails, DNS, access to Internet. All users that connect to the system through OpenVPN then have full access to it and to the Internet. My current setup is:

iptables -P INPUT ACCEPT
iptables -F
iptables -X
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 1194 -j ACCEPT
iptables -P INPUT DROP
iptables -A OUTPUT -p tcp -m tcp --sport 22 -j ACCEPT
iptables -A OUTPUT -p tcp -m tcp --sport 1194 -j ACCEPT
iptables -P OUTPUT DROP

I would like to blacklist all IPs that attack me or try to scan me. Whoever has 3 failed ssh attempts then get blacklisted for 24 hours. Is it possible to help me please?

  • i am looking for an iptables enrichment before using fail2ban and denyhosts. – john Jul 28 '16 at 8:31

I recommend that you get a firewall management software like Shorewall and learn to configure it. It takes care of many not-so-trivial rules that are useful in addition to simple port blocking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.