![在 CentOS 7 中阻止除特定 ip 之外的所有特定服务](https://linux22.com/image/35404/%E5%9C%A8%20CentOS%207%20%E4%B8%AD%E9%98%BB%E6%AD%A2%E9%99%A4%E7%89%B9%E5%AE%9A%20ip%20%E4%B9%8B%E5%A4%96%E7%9A%84%E6%89%80%E6%9C%89%E7%89%B9%E5%AE%9A%E6%9C%8D%E5%8A%A1.png)
在需要完全不对公众开放的 CentOS 7 Web 服务器中,我需要阻止所有 IP 地址,然后只允许指定的 IP 地址访问指定的服务。 我该如何配置 Firewalld 来实现这一点?
我读另一个帖子,但它似乎并没有解决我的用例,因为它主要是提供对特定 IP 地址的全面访问,而不是对不同的 IP 地址提供不同类型的访问。其他帖子没有解决电子邮件问题。另外,另一篇文章似乎假设使用锁定模式。我的问题是询问是否在此用例中使用锁定模式。
服务器上需要启用四个服务。
1.) ssh access only to one administrator at either of 2 ip addresses
2.) https access only to 30 ip addresses of users, including administrator
3.) encrypted emails:
sent to the 30 users who have https access
sent to and received from another list of known email addresses
4.) encrypted ftp upload from another list of known ip addresses
所有其他入站和出站访问都需要被阻止。
我必须设置Lockdown=yes
才能完成此任务吗?
另外,我是否可以按如下方式添加每个用户:
rule family="ipv4" source address="192.168.0.0" service name="tftp" log prefix="tftp" level="info" limit value="1/m" accept
rule family="ipv4" source address="192.235.89.45" service name="https" accept
rule family="ipv4" source address="192.235.89.45" service name="ssh" accept
rule family="ipv4" source address="192.987.376.97" service name="https" accept
目前,firewall-cmd --list-all
返回以下内容:
public (default, active)
interfaces: enp3s0
sources:
services: dhcpv6-client https ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules: