Question
How to Add Host Access Control rules via command line in AlmaLinux 8 and CloudLinux 8?
Answer
To control the Host Access Controls from the command line in AlmaLinux, this requires managing the rules via the nft command itself.
To list the current Host Access Control rules, use the following command:
# nft -a list chain inet filter cPanel-HostAccessControl
To add a new rule, add the desired ruleset to the cPanel-HostAccessControl filter. For example, the following adds an ALLOW rule for IP 203.0.113.2 to port 2087:
# nft add rule inet filter cPanel-HostAccessControl ip saddr 203.0.113.2 ct state new tcp dport 2087 counter packets 0 bytes 0 accept
-
To delete a rule, the ruleset's handle must be used. List the current rules:
# nft -a list chain inet filter cPanel-HostAccessControl
-
The output will include the "handle", such as the following.
# nft -a list chain inet filter cPanel-HostAccessControl table inet filter {
chain cPanel-HostAccessControl { # handle 4
ip saddr 203.0.113.2 ct state new tcp dport 2087 counter packets 0 bytes 0 accept # handle 40
}
}
Note the handle number that you want to remove.
-
Use the handle number to remove the entry:
# nft delete rule inet filter cPanel-HostAccessControl handle ##
Note: Replace
##with the handle number. In this example, would be "40".
Comments
0 comments
Article is closed for comments.