大网数据广告活动
服务器运维问答

firewalld is not working in CentOS 8: no rule at all is created in iptables

· 52CE 我爱测

I've recently upgraded a clean install CentOS 7 to CentOS 8 using this tutorial: https://www.tecmint.com/upgrade-centos-7-to-centos-8/ I had no extra software installed, only the base install. After upgrading, the first thing I t…

问题原文

原帖链接 · Rodrigo Renie · CC BY-SA 4.0

I've recently upgraded a clean install CentOS 7 to CentOS 8 using this tutorial:

https://www.tecmint.com/upgrade-centos-7-to-centos-8/

I had no extra software installed, only the base install. After upgrading, the first thing I tried to do was to open doors only to SSH and HTTP, so I enabled and start firewalld:

systemctl enable firewalld
systemctl start firewalld
systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-12-24 11:05:50 -02; 10min ago
     Docs: man:firewalld(1)
 Main PID: 7620 (firewalld)
    Tasks: 2 (limit: 17886)
   Memory: 22.1M
   CGroup: /system.slice/firewalld.service
           └─7620 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork --nopid

dez 24 11:05:49 renie.cc systemd[1]: Stopped firewalld - dynamic firewall daemon.
dez 24 11:05:49 renie.cc systemd[1]: Starting firewalld - dynamic firewall daemon...
dez 24 11:05:50 renie.cc systemd[1]: Started firewalld - dynamic firewall daemon.

Then added ssh and http services:

firewall-cmd --add-service http
firewall-cmd --add-service http --permanent
firewall-cmd --add-service ssh
firewall-cmd --add-service ssh --permanent
firewall-cmd --add-service ssh
firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources: 
  services: http ssh
  ports: 
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

But I see no rule at all in IPTables:

iptables -nvL
Chain INPUT (policy ACCEPT 143 packets, 13998 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 114 packets, 13295 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Even after rebooting the server, no rules are created. Could this be caused by the CentOS 7 → CentOS 8 upgrade?

I did not tested or used firewalld before upgrading this server, but I have others CentOS 7 servers which have working firewalld.

Is there any log I can analyse in order to debug the problem?

Thanks in advance.

已采纳解答

原帖链接 · A.B · CC BY-SA 4.0

Because you don't see any iptables rule, doesn't mean firewalld is not working. Actually firewalld switched to using nftables as backend. So you can find your rules with for example:

nft list ruleset

The rules you added for ssh and http would likely be in the chain filter_IN_public_allow:

        chain filter_IN_public_allow {
                tcp dport ssh ct state new,untracked accept
                tcp dport http ct state new,untracked accept
        }

You will probably also find empty iptables rules (but seen as nftables rules) in the output of nft list ruleset, because iptables is using the nftables compatibility kernel API:

# iptables -V
iptables v1.8.2 (nf_tables)

useful link: Redhat - Firewalld: The Future is nftables

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-12-24)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。