Skip to content

Instantly share code, notes, and snippets.

@gdamjan
Created September 17, 2024 22:31
Show Gist options
  • Save gdamjan/d7e6a67feae45c1f2b199e7bc605a0cc to your computer and use it in GitHub Desktop.
Save gdamjan/d7e6a67feae45c1f2b199e7bc605a0cc to your computer and use it in GitHub Desktop.
nftables to drop packets incoming for a cgroup
table ip myservice
delete table ip myservice
table ip myservice {
chain incoming {
type filter hook input priority filter; policy accept;
# `level 5` must match the number of levels of directories in the cgroup
socket cgroupv2 level 5 "user.slice/user-1000.slice/[email protected]/app.slice/[email protected]" counter
socket cgroupv2 level 5 "user.slice/user-1000.slice/[email protected]/app.slice/[email protected]" drop
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment