EGR059 - iptables Chain Not on the Host
Agent error code #EGR059 indicates that the iptables chain an egress knoc names is not on the agent host. On iptables each knoc owns a chain your ruleset declares, and the agent writes the knoc's accepts, and its rejects when it has them, into that chain. knocker enable egress makes KNOCKNOC_EGRESS_1, KNOCKNOC_EGRESS_2 and KNOCKNOC_EGRESS_3 once, but the agent never creates a chain. With the chain missing from the filter table of every family the knoc's destinations are in, there is nowhere to write the grant, and it fails.
The agent writes to each family that has the chain. A knoc with only IPv4 destinations needs the chain only in the IPv4 filter table. A knoc with destinations in both families works with the chain in one of them, and Validate integration warns that the other family's destinations are not opened.
Common causes include:
- The chain was never created, or was created in another table such as
mangle - A firewall reload removed it. A full restore (
iptables-restore,netfilter-persistent, Shorewall) drops every chain the ruleset does not declare, including the onesknocker enable egressmade - The knoc names the chain differently from your ruleset. Chain names are case sensitive
- Shorewall dropped the chain. With
OPTIMIZE=All, the default since Shorewall 5.1.0, an action with no rules compiles to nothing - A firewall reload was in progress when the grant was written. The agent writes the grant again once the chain is back
Steps to Resolve
Check the Chain
On the agent host, list it in each family:
sudo iptables -S KNOCKNOC_EGRESS_1
sudo ip6tables -S KNOCKNOC_EGRESS_1
"No chain/target/match by that name", or on iptables-nft "is incompatible, use 'nft' tool", means the chain is not there.
Declare the Chain in Your Ruleset
Declare the chain in whatever loads your firewall, so a reload keeps it. knocker enable egress writes an example to /opt/knocknoc-agent/share/egress-iptables.example. In iptables-save form:
*filter
:OUTPUT DROP [0:0]
:KNOCKNOC_EGRESS_1 - [0:0]
:KNOCKNOC_EGRESS_2 - [0:0]
:KNOCKNOC_EGRESS_3 - [0:0]
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -m owner --uid-owner 0 -j ACCEPT
COMMIT
Leave the chain empty in your ruleset. The agent fills it within about 10 seconds of a reload, and puts back the knoc's jump from OUTPUT when the knoc has one.
On Shorewall
Declare the chain as an action, and give the action file one rule that never matches so Shorewall keeps it:
- Add
KNOCKNOC_EGRESS_1to/etc/shorewall/actions - Put
REJECT - 192.0.2.1in/etc/shorewall/action.KNOCKNOC_EGRESS_1. 192.0.2.1 is a documentation address that nothing sends to, and the agent replaces the rule at its first write - Jump to the action from
/etc/shorewall/rules, or turn on the knoc's jump from OUTPUT - Run
shorewall check, thenshorewall reload
Check the Knoc Names the Chain
Open the knoc in Knocknoc and check Chain matches the chain on the host exactly. Validate integration checks the chain is in each family the destinations need and that something jumps to it.