[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
<>出现的问题
虚拟机:centos
想使用
service iptables start
这个命令打开防火墙,然后出现了如下的提示
Failed to start iptables.service: Unit iptables.service not found.
即找不到iptables.service这个服务
<>怎么解决
第一,我们要知道centos7.0之前使用service这个命令管理服务,centos7.0之后使用systemctl命令管理服务程序,也就是说解决方式1是换个命令
第二,可以下载iptables-services。
格式分别如下:
service 服务名【start/stop/restart/reload/status】
systemctl 【start/stop/restart/reload/status】服务名
<>1. 使用systemctl命令
在CentOS 7或RHEL 7或Fedora中防火墙由firewalld来管理
添加
firewall-cmd --zone=public --add-port=80/tcp --permanent
(–permanent表示永久生效,没有此参数重启后会失效)
添加范围例外端口 如 1000-2000:
firewall-cmd --zone=public --add-port=1000-2000/tcp --permanent
重新载入
firewall-cmd --reload
查看
firewall-cmd --zone=public --query-port=80/tcp
删除
firewall-cmd --zone=public --remove-port=80/tcp --permanent
开启防火墙
systemctl start firewalld.service
//或者省略firewalld.service后面的.service也可以,下面一条命令也一样。
关闭防火墙
systemctl stop firewalld.service
查看运行状态
firewall-cmd --state
//running 表示运行
补充下面一种情况
systemctl 启动 firewalld 时出现 Failed to start firewalld.service: Unit is masked.
//这说明这里命令被锁定住了,你不能进行start或者stop等其他的操作,想要操作就必须先解锁
锁定服务命令
systemctl mask firewalld
会出现如下提示
Created symlink /etc/systemd/system/firewalld.service → /dev/null.
解除锁定
systemctl unmask firewalld
出现如下提示
Removed /etc/systemd/system/firewalld.service.
<>2. 继续使用service
首先安装iptables-services
yum install iptables-services
但如若是centos7及以上版本的会显示如下的信息
让你使用systemctl命令,而不是继续用service命令(妈了个巴子,搞来搞去还是用systemctl命令)
systemctl stop iptables systemctl start iptables systemctl restart iptables
systemctl reload iptables
此时就把问题解决了,机智如我。。。哈哈哈哈(仰天长笑)
感谢阅读。。。有错请指出,一起努力进步。。。