Linux防火墙常用命令
Linux的防火墙体系主要工作在网络层,针对TCP/IP数据包实施过滤和限制,属于典型的包过滤防火墙(或网络层防火墙)。在Linux中netfilter和iptables都是指Linux防火墙。区别在于:
netfilter:指的是Linux内核中实现包过滤防火墙的内部结构,不以程序或文件的形式存在,属于“内核态”的防火墙功能体系。
iptables:指的是用来管理Linux防火墙的命令程序,通常位于/sbin/iptables,属于“用户态”的防火墙管理体系。
一、iptables防火墙
1、基本操作
查看防火墙状态
service iptables status
停止防火墙
service iptables stop
启动防火墙
service iptables start
重启防火墙
service iptables restart
永久关闭防火墙
chkconfig iptables off
永久关闭后重启
chkconfig iptableson
二、防火墙 (firewall)
1、查看firewall服务状态
systemctl status firewalld
出现Active: active (running)切高亮显示则表示是启动状态。
出现Active: inactive (dead)灰色表示停止,看单词也行。
2、查看firewall的状态
firewall-cmd --state
3、开启、重启、关闭、firewalld.service服务
开启
service firewalld start
重启
service firewalld restart
关闭
service firewalld stop
4、查看防火墙规则
firewall-cmd --list-all
5、查询、开放、关闭端口
查询端口是否开放
firewall-cmd --query-port=8080/tcp
开放80端口
firewall-cmd --permanent --add-port=80/tcp
移除端口
firewall-cmd --permanent --remove-port=8080/tcp
重启防火墙(修改配置后要重启防火墙)
firewall-cmd --reload
参数解释
1、firwall-cmd:是Linux提供的操作firewall的一个工具;
2、--permanent:表示设置为持久;
3、--add-port:标识添加的端口;
此文章为综合总结,仅供参考~
上一篇: HTML5的新特性有哪些!
下一篇: MySql数据库优化方案
评论列表