SUSE Enterprise Server 12 SP3 64 设置防火墙开放8080端口,出现Unsafe permissions for file /etc/sysconfig/SuSEfirewall2 to be sourced

时间:2021-06-13 23:26:09

SUSE Enterprise Server  12 SP3 64 设置防火墙开放8080端口时出现  Unsafe permissions for file /etc/sysconfig/SuSEfirewall2 to be sourced ,

解决办法如下

1、sudo chmod a+w /etc/sysconfig/SuSEfirewall2 #授编辑权限

(注意:这里授权,编辑保存之后,步骤3的下面一定要取消编辑权限,sudo chmod a-w /etc/sysconfig/SuSEfirewall2,

否则重启无效会提示:Unsafe permissions for file /etc/sysconfig/SuSEfirewall2 to be sourced  )

2、vi SuSEfirewall2 或者直接打开SuSEfirewall2文件进行编辑

3、编辑内容:在文件SuSEfirewall2中找到FW_SERVICES_EXT_TCP,在其后面加上服务名或者是服务对应的端口,

如SSH,FW_SERVICES_EXT_TCP=”ssh” 或 FW_SERVICES_EXT_TCP=”22″ 或者FW_SERVICES_EXT_TCP=”8080″,

如果要开放多个端口则为 FW_SERVICES_EXT_TCP=”8080 89″ #多个端口用空格分开,保存之后退出。

4、取消授权(如果没有取消编辑权限,重启无效会提示:Unsafe permissions for file /etc/sysconfig/SuSEfirewall2 to be sourced)

sudo chmod a-w /etc/sysconfig/SuSEfirewall2

5、重启防火墙,以使配置生效

第一种方式:

  执行SuSEfirewall2 stop和SuSEfirewall2 start两句

执行 a:SuSEfirewall2 stop

结果:

     <38>May 16 14:55:39 SuSEfirewall2[10860]: Firewall rules unloaded.

执行 b:SuSEfirewall2 start

结果:

     <38>May 16 14:55:54 SuSEfirewall2[10914]: Setting up rules from /etc/sysconfig/SuSEfirewall2 ...

                   <38>May 16 14:55:55 SuSEfirewall2[10914]: Firewall rules successfully set

第二种方式:

  sudo rcSuSEfirewall2 restart