网站首页 > linux / 正文
前言
从Centos6升级到Centos7,防火墙命令变化了,但是还是习惯以前的iptables命令。本文记录如何开启iptables规则的防火墙。
1.Centos7自带防火墙关闭
- 查看防火墙状态
# firewall-cmd --state
not running
- 停止firewall
# systemctl stop firewalld.service
- 禁止firewall开机启动
# systemctl disable firewalld.service
2.安装配置iptables
- 安装
# yum install -y iptables-services
- 编辑防火墙配置文件
这个是默认规则
# vim /etc/sysconfig/iptables
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
修改规则保存退出
- 重启防火墙
# systemctl restart iptables.service #最后重启防火墙使配置生效
3.其他命令
# 设置防火墙开机启动
# systemctl enable iptables.service
# 禁止iptables服务
# systemctl disable iptables
# 暂停服务
# systemctl stop iptables
# 解除禁止iptables
# systemctl enable iptables
# 开启服务
# systemctl start iptables
Tags:关闭linux防火墙命令
- 上一篇:Linux的防火墙是怎么工作的?
- 下一篇:linux命令-centos7防火墙
猜你喜欢
- 2024-11-26 CentOS7 设置防火墙、开放指定端口操作
- 2024-11-26 Linux系统中的防火墙主要有两种
- 2024-11-26 Iptables 教程 – 使用 Linux 防火墙保护 Ubuntu VPS
- 2024-11-26 Centos7版本不能解压*.zip格式文件
- 2024-11-26 什么是linux防火墙?让首批红帽授权认证专家为你详细解答
- 2024-11-26 学习笔记-Linux 防火墙 - Firewall-cmd
- 2024-11-26 Linux防火墙Iptables与Firewalld的学习总结!PDF版可领取
- 2024-11-26 Linux防火墙基础和iptables命令文档,看完终于明白了
- 2024-11-26 linux怎么看防火墙是否开启?删除iptables规则
- 2024-11-26 linux命令-centos7防火墙