Centos7关闭默认防火墙firewall和启用iptables操作

admin3年前主机评测116

centos7如何关闭默认防火墙firewall?

关闭了默认防火墙后,我们如何启用iptables防火墙呢?在使用Docker时,启用centos7默认的firewall,启动端口映射时,防火墙规则不生效。docker默认使用了iptables防火墙机制。所以需要关闭firewall使用iptables解决。今天,小编教大家如何关闭firewall和启用iptables的相关操作!

1.关闭默认的firewall防火墙

systemctl stop firewalld.service关闭防火墙

2.关闭开机启动

systemctl disable firewalld.service

3.安装开启iptables防火墙

yum install iptables(根据centOS7的版本和内核,有些版本已经装过,可以跳过此命令)

yum install iptables-services

service iptables restart

4. 设置iptables防火墙开机启动

sudo systemctl enable iptables

或者

systemctl enable iptables.service

5.禁用22端口添加指定ip访问指定端口

vim /etc/sysconfig/iptables

-A INPUT -p tcp -m state –state NEW -m tcp –dport 22 -j DROP

-A INPUT -s 192.168.255.13 -p tcp -m state –state NEW -m tcp –dport 22 -j ACCEPT

6.重启防火墙:

systemctl restart iptables

最后:

通过以上操作就可以实现“Centos7关闭默认防火墙firewall和启用iptables操作”,如果因为版本问题或系统问题导致无法实现,可以自己百度了解一下相关知识!

免责声明:本文内容来自用户上传并发布,站点仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请核实广告和内容真实性,谨慎使用。

相关文章

如何在CentOS 8服务器上使用FirewallD设置防火墙?_技术文档

如何在CentOS 8服务器上使用firewalld设置防火墙?本教程中,我们将向您展示如何在香港服务器CentOS 8系统上使用FirewallD设置防火墙。FirewallD是iptables服务...

centos7防火墙firewalld的安装与使用_技术文档

centos7防火墙firewalld如何安装?防火墙能有效的过滤掉非授权端口的请求,是保障服务器的第一步。在centos里可以安装诸多防火墙软件,诸如firewalld、iptables、ufw等,...

centos7如何查看firewall防火墙状态:开启/关闭/重启防火墙_技术文档

centos7如何查看firewall防火墙状态?systemctl status firewalld.service 运行上述命令后,如果看到有绿色字样标注的“active(running)”,说明...

centos7.6版本firewall防火墙限制某个IP访问指定端口

centos7firewall防火墙很好用,最近总被黑客入侵服务器系统,搞的很不耐烦,通过大佬的指点,知道怎么限制IP和端口了,先感谢DS大佬。CentOS7默认没有安装iptables,可以手动安装...