Configure which hosts can participate in CFEngine infrastructure management

Posted by Craig Comstock
May 6, 2024

Two modules are available for this task: allow-all-hosts and allow-hosts.

The first module, allow-all-hosts, configures the most open situation which is to accept hosts from anywhere. This is only recommended in network restricted environments such as a local machine’s virtual machine network or other such closed down situations.

The second module, allow-hosts, uses cfbs module input to let you decide which hosts (specified by IP addresses and subnets) are allowed to connect to your hub, authenticate, fetch policy, etc. This is by far the more common scenario.

By default the hub will accept requests from hosts on it’s own subnet e.g. hub-ip/16.

Add the allow-hosts module

When you install allow-hosts in the Build app in Mission Portal you will see an input field to enter one or more allowed hosts.

allow-hosts module added and editing an entry

I add several IPs for hosts in my environment, including the hub itself,

list of IP address to allow to connect

and then make sure I push and deploy the policy:

Push and deploy button in Mission Portal Build application

Remove an IP and test

Next I remove one hosts IP: and test if it can connect and pull policy from the hub.

list of IP addresses with removed

The ip a command shows the IP address:

ip a | grep 192
inet brd scope global dynamic noprefixroute wlp3s0

If we try to fetch policy we see that the hub rejects the connection:

cf-agent -KIf
error: Failed to establish TLS connection: underlying network error (Connection reset by peer)
 info: Unable to establish connection to ''

The policy that has already been fetched will still be used but updates will not be received.

When I add that IP address back in, it can fetch policy again as desired.

Test with cf-net

An alternate way to test connectivity would be to use cf-net command:

cf-net -H opendir /var/cfengine/data

and if the IP is not included in the list of IPs you would get

cf-net -H opendir /var/cfengine/data
error: Failed to establish TLS connection: underlying network error (Connection reset by peer)
Failed to connect to ''


If you have questions or need help reach out on the mailing list or GitHub discussions. If you have a support contract feel free to open a ticket in our support system.