有个 centos 7 的机器, firewall 默认 9 个 zone 多出来 2 个, 如何删除?
多出来 2 个中有个还是 default, 我更改为 public 后, 网络访问有问题. 请问该如何清除掉所有的设置, 这样重置后按照再根据自己需求新增加各种端口限制?
机器里面跑了个 docker,且发现 docker zone 是默认,不过可以删除掉,从而实现上述要求.
1
yanqiyu 2023-03-20 00:01:42 +08:00
> 请问该如何清除掉所有的设置
如果是还原初始状态可以清除掉 /etc/firewalld 下面的几个文件夹(比如 zones)的文件。就可以还原 firewalld 的 zone 设置了。 |
2
iGuChin OP @yanqiyu
里面有这几个文件: docker.xml docker.xml.old iredmail.xml iredmail.xml.old public.xml public.xml.old 其中 iredmail 是邮件服务器非基于 docker 安装. 目前提示默认 zone 是 docker( 系统中装了 docker 和 portainer) 但是我想改为默认的 public |
3
iGuChin OP 现在我是每个 zone 都加上想要开放的端口, 从而避免网络不通发生:
docker.xml <?xml version="1.0" encoding="utf-8"?> <zone version="1.0" target="ACCEPT"> <short>docker</short> <description>zone for docker bridge network interfaces</description> <port protocol="tcp" port="2222"/> <port protocol="tcp" port="55555"/> <port protocol="tcp" port="33333"/> <port protocol="tcp" port="80"/> <port protocol="tcp" port="443"/> <port protocol="tcp" port="25"/> <port protocol="tcp" port="587"/> <port protocol="tcp" port="465"/> <port protocol="tcp" port="110"/> <port protocol="tcp" port="993"/> <port protocol="tcp" port="995"/> <port protocol="tcp" port="9000"/> </zone> --------------------------------------------------------------- iredmail.xml <?xml version="1.0" encoding="utf-8"?> <zone> <short>Mail services</short> <description>Allow access to mail services from external network.</description> <service name="http"/> <service name="https"/> <service name="smtp"/> <service name="smtp-submission"/> <service name="pop3"/> <service name="pop3s"/> <service name="imap"/> <service name="imaps"/> <service name="ssh"/> <port protocol="tcp" port="2222"/> <port protocol="tcp" port="55555"/> <port protocol="tcp" port="33333"/> <port protocol="tcp" port="80"/> <port protocol="tcp" port="443"/> <port protocol="tcp" port="25"/> <port protocol="tcp" port="587"/> <port protocol="tcp" port="465"/> <port protocol="tcp" port="110"/> <port protocol="tcp" port="993"/> <port protocol="tcp" port="995"/> <port protocol="tcp" port="9000"/> <icmp-block-inversion/> <rule> <protocol value="icmp"/> <drop/> </rule> </zone> ---------------------------------------------- public.xml <?xml version="1.0" encoding="utf-8"?> <zone> <short>Public</short> <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description> <service name="dhcpv6-client"/> <service name="ssh"/> </zone> |
4
yanqiyu 2023-03-20 09:59:20 +08:00
firewall-cmd --set-default-zone 就可以设置默认的 zone
|