CentOS6关闭防火墙使用以下命令,

//临时关闭
service iptables stop
//禁止开机启动
chkconfig iptables off

CentOS7中若使用同样的命令会报错,

stop  iptables.service
Failed to stop iptables.service: Unit iptables.service not loaded.

这是因为CentOS7版本后防火墙默认使用firewalld,因此在CentOS7中关闭防火墙使用以下命令,

//临时关闭
systemctl stop firewalld
//禁止开机启动
systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

1、firewalld的基本使用

启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld 
开机禁用  : systemctl disable firewalld
开机启用  : systemctl enable firewalld
 
 
2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed

3.配置firewalld-cmd

查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息:  firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic
 
那怎么开启一个端口呢
添加
firewall-cmd --zone=public --add-port=80/tcp --permanent    (--permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd --reload
查看
firewall-cmd --zone= public --query-port=80/tcp
删除
firewall-cmd  --remove-port=80/tcp --permanent
---------------------------------------------------------------------------
centos6关闭防火墙
先进入init.d目录,命令如下:
[root@centos6 ~]# cd /etc/init.d/

[root@centos6 init.d]#

然后
查看防火墙状态:
[root@centos6 init.d]# /etc/init.d/iptables status

暂时关闭防火墙:
[root@centos6 init.d]# /etc/init.d/iptables stop

重启iptables:
[root@centos6 init.d]# /etc/init.d/iptables restart
 
centos6 开启端口:
写入修改
        /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT   
保存修改 
         /etc/init.d/iptables save   
 重启防火墙,修改生效
        service iptables restart    

最新文章

  1. 添加文件到HDFS的集中缓存
  2. VS2010部署Asp.net程序到本地IIS 7
  3. api get
  4. CUnit的用法
  5. Java中使用split、sort函数
  6. Flex httpservice返回值类型和处理 (转)
  7. VIM下CS命令
  8. CentOS下yum安装mysql,jdk以及tomcat
  9. 随机数(random)
  10. IntelliJ IDEA中创建并运行scala应用程序
  11. hdu 4630 查询[L,R]区间内任意两个数的最大公约数
  12. Fastjson 1.2.22-24 反序列化漏洞分析
  13. PAT1018 Public Bike Management【dfs】【最短路】
  14. RandomStringUtils的使用
  15. 使用 Composer 查看 FastAdmin 项目 组件的版本
  16. pyqt4 利用信号槽在子线程里面操作Qt界面
  17. HTTP协议之响应头Date与Age
  18. L1-050 倒数第N个字符串
  19. php后台+前端开发过程整理
  20. Qt Lighthouse学习(二),就是QPA(Qt Platform Abstraction) 项目的名字

热门文章

  1. 使用git下载文件时提示身份验证失败
  2. GuiLite 学习笔记(一) Mainloop与ViewTree
  3. [Oracle19C 数据库管理] 用户与权限管理
  4. mysql慢sql监控
  5. 从零搭建hadoop集群之hadoop集群安装
  6. spring 使用@Async注解实现异步调用
  7. mi
  8. centos6根分区扩容,非lvm
  9. @order(1)
  10. Supervisor安装及配置