Firewalld 如何禁止外部访问端口?

我使用 Docker Compose 布置了几个本地用的服务,但是这几个服务可以被局域网内的其他设备访问。我现在希望只有指定的防火墙区域才能访问 Docker 设置的服务,请问该怎么做呢?

阅读 4.4k
1 个回答

参考:https://tecadmin.net/open-spe...

摘要:

Allow Port for Specific IP

You can also restrict access on any port based on source address. To open port access based on source address needed to add firewall rich rule.

Run the below command to allow access for port 4567 to 192.168.0.0/24 network.

firewall-cmd --permanent --zone=public --add-rich-rule='
  rule family="ipv4"
  source address="192.168.0.0/24"
  port protocol="tcp" port="4567" accept'

Reload the firewall rules to apply changes.

firewall-cmd --reload
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题