[root@test ~]# service iptables save
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
[root@test ~]# service iptables restart
Redirecting to /bin/systemctl restart iptables.service
Failed to restart iptables.service: Unit not found.
[root@test ~]# sudo ufw status
sudo: ufw:找不到命令
[root@test ~]# systemctl stop firewalld
[root@test ~]# systemctl mask firewalld
Created symlink from /etc/systemd/system/firewalld.service to /dev/null.
[root@test ~]# yum install iptables-services
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirrors.bfsu.edu.cn
base                                                                                                                           | 3.6 kB  00:00:00     
extras                                                                                                                         | 2.9 kB  00:00:00     
updates                                                                                                                        | 2.9 kB  00:00:00     
(1/3): extras/7/x86_64/primary_db                                                                                              | 222 kB  00:00:00     
(2/3): base/7/x86_64/primary_db                                                                                                | 6.1 MB  00:00:00     
(3/3): updates/7/x86_64/primary_db                                                                                             | 3.7 MB  00:00:01     
正在解决依赖关系
--> 正在检查事务
---> 软件包 iptables-services.x86_64.0.1.4.21-35.el7 将被 安装
--> 正在处理依赖关系 iptables = 1.4.21-35.el7,它被软件包 iptables-services-1.4.21-35.el7.x86_64 需要
--> 正在检查事务
---> 软件包 iptables.x86_64.0.1.4.21-28.el7 将被 升级
---> 软件包 iptables.x86_64.0.1.4.21-35.el7 将被 更新
--> 解决依赖关系完成

依赖关系解决

======================================================================================================================================================
 Package                                   架构                           版本                                     源                            大小
======================================================================================================================================================
正在安装:
 iptables-services                         x86_64                         1.4.21-35.el7                            base                          52 k
为依赖而更新:
 iptables                                  x86_64                         1.4.21-35.el7                            base                         432 k

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

总下载量:485 k
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for base
(1/2): iptables-services-1.4.21-35.el7.x86_64.rpm                                                                              |  52 kB  00:00:00     
(2/2): iptables-1.4.21-35.el7.x86_64.rpm                                                                                       | 432 kB  00:00:00     
------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                  1.9 MB/s | 485 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : iptables-1.4.21-35.el7.x86_64                                                                                                     1/3 
  正在安装    : iptables-services-1.4.21-35.el7.x86_64                                                                                            2/3 
  清理        : iptables-1.4.21-28.el7.x86_64                                                                                                     3/3 
  验证中      : iptables-services-1.4.21-35.el7.x86_64                                                                                            1/3 
  验证中      : iptables-1.4.21-35.el7.x86_64                                                                                                     2/3 
  验证中      : iptables-1.4.21-28.el7.x86_64                                                                                                     3/3 

已安装:
  iptables-services.x86_64 0:1.4.21-35.el7                                                                                                            

作为依赖被升级:
  iptables.x86_64 0:1.4.21-35.el7                                                                                                                     

完毕!
[root@test ~]# systemctl enable iptables
Created symlink from /etc/systemd/system/basic.target.wants/iptables.service to /usr/lib/systemd/system/iptables.service.
[root@test ~]# systemctl start iptables
[root@test ~]# 

Reference:
How can i use iptables on centos 7? [closed]

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐