linux 防火墙启动命令

查看防火状态

 - systemctl status firewalld 
 - service iptables status

关闭防火墙

 - systemctl stop firewalld 
 - service iptables stop

永久关闭防火墙

 - systemctl disable firewalld
 - chkconfig iptables off

重启防火墙

 - systemctl enable firewalld 
 - service iptables restart

开启防护墙

- systemctl start firewalld

查看所有打开的端口:firewall-cmd --zone=public --list-ports
查看当前所有tcp端口:netstat -ntlp
开放端口永久生效:firewall-cmd --zone=public --add-port=80/tcp --permanent
Linux系统中,有两种常见的防火墙软件:iptables(基于内核模块)和firewalld(作为独立服务)。下面是这两种防火墙启动命令: 1. **iptables(基于命令行)**: 如果您想通过命令行操作iptables,通常不需要特别启动服务,因为它是内建到Linux核心的。你可以通过运行以下命令查看当前状态并管理规则: ```bash sudo iptables-save # 查看当前规则 sudo iptables-restore < rules.txt # 应用保存的规则文件 sudo service iptables save # 保存当前规则到rules.txt文件 ``` 2. **ufw(用户空间防火墙)**: UFW是一个更直观的图形化界面工具,适合对iptables不太熟悉的人。ufw不需要单独启动,它依赖于iptables。启动和使用ufw: ```bash sudo ufw enable # 启用ufw sudo ufw status numbered # 显示规则列表 sudo ufw allow/tcp 80 # 允许HTTP流量 ``` 3. **firewalld(系统服务)**: firewalld作为一个独立的服务,它的启动和关闭可以通过systemctl命令: ```bash sudo systemctl start firewalld # 启动firewalld sudo systemctl status firewalld # 检查状态 sudo systemctl enable firewalld # 设置开机自启 sudo firewall-cmd --permanent --add-service=http # 添加HTTP服务规则 sudo firewall-cmd --reload # 刷新规则 ``` 请注意,上述命令可能会因Linux发行版和个人偏好而略有不同。在实际操作前,请确认您的Linux系统版本和安装的防火墙工具。如果你不确定,可以查阅官方文档或者使用`man firewall`或`man ufw`获取帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值