赞
踩
场景:在公司AlmaLinux release 8.6 (Sky Tiger)环境下试图用iptables放行VPN端口的时候发现报错,无法正常运行,连保存iptbales写入指令也不行。
1、iptables:restorecon: command not found无法保存策略
2、iptables重启失败
复现问题:
service iptables save
无法保存的错误提示:
iptables: Saving firewall rules to /etc/sysconfig/iptables: /etc/init.d/iptables: line 268: restorecon: command not found
1、查询restorecon命令.:
which restorecon
whereis restorecon
2、没结果,查询过滤系统相关二进制程序文件:
ll /sbin/ | grep restore
3、无相关的文件,大概是包没装
查找相关包:
1、yum search restorecon
2、yum provides restorecon //通过这个方式找到了相关包名:
"policycoreutils-2.9-20.el8.x86_64 : SELinux policy core utilities" //缺失了这个包会导致iptables策略保存失败且会导致iptables服务启动失败。
打包:yum -y install policycoreutils
打包后查询系统生成的二进制程序文件:(多出以下三条)
# ll /sbin/ | greprestore
lrwxrwxrwx 1 root root 8 Oct 8 17:14 restorecon -> setfiles
-rwxr-xr-x 1 root root 25416 Oct 8 17:14 restorecond
-rwxr-xr-x 1 root root 16800 Oct 8 17:14 restorecon_xattr
保存iptables策略:(成功)
[root@appliance ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
重启iptbales (成功)
[root@appliance ~]# systemctl restart iptables
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。