FirewallD "internal" editor broken for Ubuntu (maybe?)

I want to use checkmk to keep an eye on a Virtualmin, using the checkmk client, which installed fine.

On the FirewallD ‘internal’ zone" I did the “Add allowed service” and added the premade “checkmk-agent (6556)” service and I added the IP of my checkmk server with the “Allow IP/CIDR” button.

Prior to doing that I had only public.xml and lockdown-whitelist.xml /etc/firewalld/ files. After doing this Virtualmin added an internal.xml file as such:

<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Internal</short>
  <description>For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="ssh"/>
  <service name="mdns"/>
  <service name="samba-client"/>
  <service name="dhcpv6-client"/>
  <service name="checkmk-agent"/>
  <rule family="ipv4" priority="-32767">
    <source address="[SAID-IP-HERE]"/>
    <accept/>
  </rule>
</zone>

No amount of clicking the little “Apply” button by the “Apply rules to” (nor setting selected interfaces instead of all) or “Reload FirewallD” or stopping and starting FirewallD seems to make that work though, checkmk always comes up with:

However if I add the same rule to “public (default)” and then “Reload FirewallD” the client answers fine:

image

I can tell from the output of:

sudo tcpdump -n -i ens18 port 6556

that I have my checkmk IP right (ie virtualmin doesn’t see it the traffic as coming from somewhere else for some routing reason)

So after enough tinkering I end up manually editing the file thusly:

<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Internal</short>
  <description>For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="ssh"/>
  <service name="mdns"/>
  <service name="samba-client"/>
  <service name="dhcpv6-client"/>
  <service name="checkmk-agent"/>
  <source address="[SAID-IP-HERE]"/>
  <accept/>
</zone>

So does this imply that the Virtualmin editor is encasing the Allowed IP/CIDR into a rule that makes it thus not apply to the rest of the stuff in the file (that Virtualmin itself writes)? Or (more likely) that I don’t know what I’m doing and just opened the port to the world or broke something else down the line?

Thanks.

Ron

SYSTEM INFORMATION
OS type and version Ubuntu 24.04
Virtualmin version 7.40.1

Well, if the rest of your server works fine on the public address then my question is why does adding the client to that zone work? I don’t know your network/s setup so I can’t get past that. :wink:

I am curious, specifically, why the setup of my network would be an issue? I think maybe I’m just ignorant about how FirewallD is supposed to work.

In my imagination each of the “zones” has ports and services that are allowed through it, with “public (default)” being “available for everyone”. When I add an IP or range to another zone, that IP or range would then be able to use the ports and services in that zone (and their names or just for easier “human” organizing). (That, at least, is one dummy’s way of interpreting this web interface.)

Therefore my expectation is that adding an IP to “internal” will give that IP access to the ports and services there (in addition to the “public (default)” ones) and that no other action, save maybe an “Apply” or “Reload” would be needed on my part.

It is for that reason that I do no know what you mean really about my network/s setup.

In a fresh example case the setup is simple (from my view):

network:
  version: 2
  ethernets:
    ens18:
      addresses:
      - "[MY-IP-HERE]/22"
      nameservers:
        addresses:
        - 127.0.0.1
        - [MY-DNS-HERE]
        - [MY-DNS-HERE]
        search:
        - [MY-DOMAIN-HERE]
      routes:
      - to: "default"
        via: "[MY-GATEWAY-HERE]"

The only thing I have in /etc/firewalld/zones (at the start) is:

public.xml public.xml.old

And the live one looks like this:

<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Public</short>
  <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="ssh"/>
  <service name="dhcpv6-client"/>
  <service name="smtp"/>
  <service name="smtps"/>
  <service name="smtp-submission"/>
  <service name="ftp"/>
  <service name="pop3"/>
  <service name="pop3s"/>
  <service name="imap"/>
  <service name="imaps"/>
  <service name="http"/>
  <service name="https"/>
  <service name="dns"/>
  <service name="mdns"/>
  <service name="dns-over-tls"/>
  <port port="20" protocol="tcp"/>
  <port port="2222" protocol="tcp"/>
  <port port="10000-10100" protocol="tcp"/>
  <port port="20000" protocol="tcp"/>
  <port port="49152-65535" protocol="tcp"/>
  <forward/>
</zone>

With the addition of:

<port port="49152-65535" protocol="tcp"/>

Being the only difference between the .old and the current.

In:

Webmin > Networking > FirewallD > Edit Config Files

I have only:

If I go to:

Webmin > Networking > FirewallD

And select “internal” and then add an IP to:

A new zone file is written automatically in:

/etc/firewalld/zones:

image

or:

Like this:

<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Internal</short>
  <description>For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="ssh"/>
  <service name="mdns"/>
  <service name="samba-client"/>
  <service name="dhcpv6-client"/>
  <rule family="ipv4" priority="-32767">
    <source address="10.12.39.17"/>
    <accept/>
  </rule>
  <forward/>
</zone>

It is my observation that this does not cause the IP there to be allowed access to those services. Or at least that adding service that I can easily test:

(Which results in its addition the said new file):

<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Internal</short>
  <description>For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="ssh"/>
  <service name="mdns"/>
  <service name="samba-client"/>
  <service name="dhcpv6-client"/>
  <service name="checkmk-agent"/>
  <rule family="ipv4" priority="-32767">
    <source address="10.12.39.17"/>
    <accept/>
  </rule>
  <forward/>
</zone>

…does not allow the IP specified to connect, even after “Reload FirewallD”

image

I will continue to get this (using checkmk to test its connection):

However, if I manually edit the internal.xml file

And only remove the two lines with “rule” int them, thusly:

<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Internal</short>
  <description>For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="ssh"/>
  <service name="mdns"/>
  <service name="samba-client"/>
  <service name="dhcpv6-client"/>
  <service name="checkmk-agent"/>

    <source address="10.12.39.17"/>
    <accept/>

  <forward/>
</zone>

And then “Save and Close” and “Reload FirewallD”, my test of the checkmk agent on port 6556 works fine:

image

So in my view either:

“Webmin’s FirewallD zones interface writes incorrect .xml files.”

or:

“I do not understand how FirewallD zones are supposed to work.”

…Actually both of those things can be true at the same time.

My concern is that if this is an “I don’t know what I’m doing” thing, I have opened these services or ports to the world without realizing it (or set myself up for some such condition). I guess as a secondary concern I am worried that further edits to using the web interface will break whatever I do manually (so someday when someone else is working on this or I have totally forgotten it, all hell will break loose because someone tries to add an IP).

What is the proper use case or the obvious thing that I don’t see?

Thanks.

Ron

Because it works on the public zone.

Is the internal zone assigned to that network/NIC?

This is a network issue. A route to does not guarantee a route back. You’ve actually put it too much information in that post to easily follow.

root@main:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.255.255.1    0.0.0.0         UG    0      0        0 eth0
10.255.255.1    0.0.0.0         255.255.255.255 UH    0      0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0

I think this question might be the key to my misunderstanding of how this works:

Because my answer is “Why wouldn’t it be?” (which is the same as saying “What does that mean?” and "If I need that for the pre-built ‘internal’ Webmin FirewallD to function properly, then why wouldn’t ‘assign zone to network/NIC’ be a checkox or something?)

There is this:

image

Which sort of sounds like “assigned to that network/NIC” but it defaults to “All interfaces” and “Apply” does nothing (nor with any combination of checking the “Selected interfaces” instead).

Also is the fact that if I remove the two “rule” lines from the Webmin-generated internal.xml lines and reload it suddenly works not evidence that the zone is assigned to that network/NIC (or does that make it work for some other reason)?

<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Internal</short>
  <description>For use on internal networks. You mostly trust the other computers on the networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="ssh"/>
  <service name="mdns"/>
  <service name="samba-client"/>
  <service name="dhcpv6-client"/>
  <service name="checkmk-agent"/>
<!-- <rule family="ipv4" priority="-32767"> -->
    <source address="10.12.39.17"/>
    <accept/>
<!--  </rule> -->
  <forward/>
</zone>

Also results in:

image

Thanks.