打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Centos中iptables和firewall防火墙开启、关闭、查看状态、基本设置等

iptables防火墙

1、基本操作

  1. # 查看防火墙状态
  2. service iptables status
  3. # 停止防火墙
  4. service iptables stop
  5. # 启动防火墙
  6. service iptables start
  7. # 重启防火墙
  8. service iptables restart
  9. # 永久关闭防火墙
  10. chkconfig iptables off
  11. # 永久关闭后重启
  12. chkconfig iptables on 

2、开启80端口

  1. vim /etc/sysconfig/iptables
  2. # 加入如下代码
  3. -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

保存退出后重启防火墙

service iptables restart

firewall防火墙

1、查看firewall服务状态

systemctl status firewalld

2、查看firewall的状态

firewall-cmd --state

3、开启、重启、关闭、firewalld.service服务

  1. # 开启
  2. service firewalld start
  3. # 重启
  4. service firewalld restart
  5. # 关闭
  6. service firewalld stop

4、查看防火墙规则

firewall-cmd --list-all 

5、查询、开放、关闭端口

  1. # 查询端口是否开放
  2. firewall-cmd --query-port=8080/tcp
  3. # 开放80端口
  4. firewall-cmd --permanent --add-port=80/tcp
  5. # 移除端口
  6. firewall-cmd --permanent --remove-port=8080/tcp
  7. #重启防火墙(修改配置后要重启防火墙)
  8. firewall-cmd --reload
  9. # 参数解释
  10. 1、firwall-cmd:是Linux提供的操作firewall的一个工具;
  11. 2、--permanent:表示设置为持久;
  12. 3、--add-port:标识添加的端口;
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
CentOS 7/8 预装的新型防火墙firewalld配置详解,你会用吗
gitlab run成功 但无法访问
解决CentOS7关闭/开启防火墙出现Unit iptables.service failed to load: No such file or directory.
centos7防火墙firewalld设置 – 蓝队云
[ 原创 ] centos安装tomcat,启动成功 无法访问
详解centos6和centos7防火墙的关闭
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服