问题原文
原帖链接 · Mark · CC BY-SA 4.0
I'm new to firewalld and centos 7.
I read other questions and I've learned about "zones" and rules.
Right now, it's in the default state:
# firewall-cmd --get-default-zone
public
# firewall-cmd --list-all
public
target: default
icmp-block-inversion: no
interfaces:
sources:
services: dhcpv6-client ftp ssh
ports: 21/tcp 80/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
Every couple of days I log in via SSH and the system tells me there were 20,000+ of failed log in attempts. It's time to set up the firewall!
My needs:
- allow SSH access only from a specific IP address
- but how to handle the unlikely event if my IP will change in the future before I can release this setting?
- allow HTTP and HTTPS web services (port 80 and 443) from any address
- block everything else
I kindly ask an help to understand how to approach this scenario - and of course if it makes sense!
已采纳解答
原帖链接 · Kate · CC BY-SA 4.0
You have several options:
- whitelist a few IP addresses if that is feasible for you
- brute force attacks against machines exposed on the Internet are a fact of life, tools like Fail2ban, CSF+LFD will help a lot
- you could set up a VPN on your server (or somewhere else if it is part of a larger infrastructure), then whitelist the VPN private IP range (eg 10.* 172.*)
- you could set up port knocking to make the SSH port stealth
Given that you seem to have a webserver and perhaps FTP, I think option #2 would be appropriate and will protect services other than SSH. You can combine more options depending on your requirements.
Regarding the webserver, a WAF (web application firewall) may be desirable too.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
