From c0548df0a2f78f3422d77c77c2149d8a7f50d8f6 Mon Sep 17 00:00:00 2001 From: Topi Miettinen Date: Sun, 22 May 2022 14:21:02 +0300 Subject: core: firewall integration with ControlGroupNFTSet= New directive `ControlGroupNFTSet=` provides a method for integrating services into firewall rules with NFT sets. Example: ``` table inet filter { ... set timesyncd { type cgroupsv2 } chain ntp_output { socket cgroupv2 != @timesyncd counter drop accept } ... } ``` /etc/systemd/system/systemd-timesyncd.service.d/override.conf ``` [Service] ControlGroupNFTSet=inet:filter:timesyncd ``` ``` $ sudo nft list set inet filter timesyncd table inet filter { set timesyncd { type cgroupsv2 elements = { "system.slice/systemd-timesyncd.service" } } } ``` --- man/systemd.resource-control.xml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'man/systemd.resource-control.xml') diff --git a/man/systemd.resource-control.xml b/man/systemd.resource-control.xml index 1397b886c5..23b2d0f390 100644 --- a/man/systemd.resource-control.xml +++ b/man/systemd.resource-control.xml @@ -1173,6 +1173,35 @@ DeviceAllow=/dev/loop-control + + ControlGroupNFTSet=family:table:set + + This setting provides a method for integrating dynamic cgroup IDs into firewall rules with + NFT sets. This option expects a whitespace separated list of NFT set definitions. Each definition + consists of a colon-separated tuple of NFT address family (one of arp, + bridge, inet, ip, ip6, + or netdev), table name and set name. The names of tables and sets must conform + to lexical restrictions of NFT table names. When a control group for a unit is realized, the cgroup + ID will be appended to the NFT sets and it will be be removed when the control group is + removed. Failures to manage the sets will be ignored. + + Example: + [Unit] +ControlGroupNFTSet=inet:filter:my_service + + Corresponding NFT rules: + table inet filter { + set my_service { + type cgroupsv2 + } + chain x { + socket cgroupv2 level 2 @my_service accept + drop + } +} + + + -- cgit v1.2.1