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

admin3年前主机评测57

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操作”,如果因为版本问题或系统问题导致无法实现,可以自己百度了解一下相关知识!

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

相关文章

CentOS7安装iptables防火墙(禁用/停止自带的firewalld服务)

centos7如何安装iptables防火墙?本篇文章主要介绍了centos7安装iptables防火墙的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。不仅有安装iptables防火墙的命...