CentOS中防火墙相关的命令(CentOS7中演示)



Last login: Sun Jan 28 22:07:10 2018 from 192.168.72.200
[wangshumin@CentOSNode2 ~]$ jps
3905 Jps
3798 Elasticsearch
[wangshumin@CentOSNode2 ~]$ firewall-cmd    --state
Authorization failed.
    Make sure polkit agent is running or run the application as superuser.
[wangshumin@CentOSNode2 ~]$ sudo  firewall-cmd    --state
[sudo] wangshumin 的密码:
对不起,请重试。
[sudo] wangshumin 的密码:
running
[wangshumin@CentOSNode2 ~]$ systemctl  stop   firewalld.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: 
polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Failed to stop firewalld.service: Access denied
See system logs and 'systemctl status firewalld.service' for details.
[wangshumin@CentOSNode2 ~]$ systemctl  stop   firewalld.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: 
==== AUTHENTICATION COMPLETE ===
[wangshumin@CentOSNode2 ~]$ firewall-cmd    --state
not running
[wangshumin@CentOSNode2 ~]$ sudo systemctl   disable   firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[wangshumin@CentOSNode2 ~]$ firewall-cmd    --state
not running

[wangshumin@CentOSNode2 ~]$ 


Last login: Sun Jan 28 22:12:03 2018 from 192.168.72.200
[wangshumin@CentOSNode1 ~]$ su
密码:
[root@CentOSNode1 wangshumin]# firewall-cmd    --state
running
[root@CentOSNode1 wangshumin]#  systemctl  stop   firewalld.service
^[[A[root@CentOSNode1 wangshumifirewall-cmd    --state
not running
[root@CentOSNode1 wangshumin]# systemctl   disable   firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@CentOSNode1 wangshumin]# yum install  iptables-services
已加载插件:fastestmirror, langpacks
base                                                                                                                                                                  | 3.6 kB  00:00:00     
extras                                                                                                                                                                | 3.4 kB  00:00:00     
updates                                                                                                                                                               | 3.4 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirrors.neusoft.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 iptables-services.x86_64.0.1.4.21-18.2.el7_4 将被 安装
--> 正在处理依赖关系 iptables = 1.4.21-18.2.el7_4,它被软件包 iptables-services-1.4.21-18.2.el7_4.x86_64 需要
--> 正在检查事务
---> 软件包 iptables.x86_64.0.1.4.21-18.0.1.el7.centos 将被 升级
---> 软件包 iptables.x86_64.0.1.4.21-18.2.el7_4 将被 更新
--> 解决依赖关系完成


依赖关系解决


=============================================================================================================================================================================================
 Package                                           架构                                   版本                                                 源                                       大小
=============================================================================================================================================================================================
正在安装:
 iptables-services                                 x86_64                                 1.4.21-18.2.el7_4                                    updates                                  51 k
为依赖而更新:
 iptables                                          x86_64                                 1.4.21-18.2.el7_4                                    updates                                 428 k


事务概要
=============================================================================================================================================================================================
安装  1 软件包
升级           ( 1 依赖软件包)


总计:479 k
总下载量:51 k
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/updates/packages/iptables-services-1.4.21-18.2.el7_4.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY          ]  0.0 B/s |    0 B  --:--:-- ETA 
iptables-services-1.4.21-18.2.el7_4.x86_64.rpm 的公钥尚未安装
iptables-services-1.4.21-18.2.el7_4.x86_64.rpm                                                                                                                        |  51 kB  00:00:07     
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
 用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 软件包     : centos-release-7-4.1708.el7.centos.x86_64 (@anaconda)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : iptables-1.4.21-18.2.el7_4.x86_64                                                                                                                                        1/3 
  正在安装    : iptables-services-1.4.21-18.2.el7_4.x86_64                                                                                                                               2/3 
  清理        : iptables-1.4.21-18.0.1.el7.centos.x86_64                                                                                                                                 3/3 
  验证中      : iptables-services-1.4.21-18.2.el7_4.x86_64                                                                                                                               1/3 
  验证中      : iptables-1.4.21-18.2.el7_4.x86_64                                                                                                                                        2/3 
  验证中      : iptables-1.4.21-18.0.1.el7.centos.x86_64                                                                                                                                 3/3 


已安装:
  iptables-services.x86_64 0:1.4.21-18.2.el7_4                                                                                                                                               


作为依赖被升级:
  iptables.x86_64 0:1.4.21-18.2.el7_4                                                                                                                                                        


完毕!
[root@CentOSNode1 wangshumin]# systemctl  start  iptables.service
[root@CentOSNode1 wangshumin]# systemctl  status  iptables.service
● iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; disabled; vendor preset: disabled)
   Active: active (exited) since 日 2018-01-28 22:34:18 CST; 38s ago
  Process: 4306 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)
 Main PID: 4306 (code=exited, status=0/SUCCESS)


1月 28 22:34:15 CentOSNode1 systemd[1]: Starting IPv4 firewall with iptables...
1月 28 22:34:17 CentOSNode1 iptables.init[4306]: iptables: Applying firewall rules: [  确定  ]
1月 28 22:34:18 CentOSNode1 systemd[1]: Started IPv4 firewall with iptables.
[root@CentOSNode1 wangshumin]# systemctl  stop  iptables.service
[root@CentOSNode1 wangshumin]# 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值