大网数据广告活动
服务器运维问答

firewalld rules to allow static IP SSH access with backdoor?

· 52CE 我爱测

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 …

问题原文

原帖链接 · 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:

  1. whitelist a few IP addresses if that is feasible for you
  2. brute force attacks against machines exposed on the Internet are a fact of life, tools like Fail2ban, CSF+LFD will help a lot
  3. 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.*)
  4. 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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-03-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。