Managing CSF Firewall Rules on CentOS 8 with nftables Print

  • 0

๐Ÿ”ฅ Managing CSF Firewall Rules on CentOS 8 with nftables

๐Ÿš€ Introduction

CentOS 8 introduces nftables as its default firewall framework, replacing the legacy iptables system. This transition means that ConfigServer Security & Firewall (CSF) now operates through an nftables compatibility layer rather than directly on iptables.

๐Ÿ“Œ Key Takeaways:

  • CentOS 8 does not support reverting to iptables-legacy.

  • CSF translates its firewall rules into nftables automatically.

  • Best practice: Let CSF manage firewall rules instead of modifying nftables manually.


๐Ÿ› ๏ธ 1๏ธโƒฃ The New Landscape: nftables on CentOS 8

๐Ÿ” What Changed?

โœ… Default Framework: CentOS 8 has fully migrated from iptables-legacy to nftables. โœ… No iptables-legacy Package: Unlike other distributions, CentOS 8 does not provide a supported way to revert to iptables-legacy.

๐ŸŽฏ Why nftables?

๐Ÿš€ Performance & Efficiency:

  • Faster processing compared to iptables.

  • Supports stateful packet filtering.

  • Provides native support for sets and maps, reducing redundancy in rule management.

๐Ÿ›ก๏ธ Modern Firewall Management:

  • Simplified syntax for rule management.

  • Enhanced security and scalability.


๐Ÿ”ฅ 2๏ธโƒฃ How CSF Operates with nftables

๐Ÿ”„ CSF and the Compatibility Layer

Originally designed for iptables, CSF now works through a nftables compatibility layer on CentOS 8.

๐Ÿ”น Automatic Translation: When you execute:

csf -r

CSF automatically translates iptables-style commands into nftables syntax.

๐Ÿ”น Managed Tables: You may see warnings like:

# Warning: table ip filter is managed by iptables-nft, do not touch!

โœ… What This Means: The system manages these tables automatically through CSF, and manual modifications are discouraged.

๐Ÿ›‘ Best Practices: Let CSF Manage the Firewall

๐Ÿšซ Avoid Manual Changes:

  • Do NOT modify the auto-generated tables using nft or direct iptables commands.

  • Instead, make all adjustments via CSF's configuration files.

โœ… Use CSF Commands:

csf -r   # Reload firewall rules
csf -g <port>  # Check rules for a specific port

๐Ÿ”ง 3๏ธโƒฃ Managing CSF Configuration on CentOS 8

๐Ÿ“ Making Adjustments via CSF

All modifications should be performed through CSF's configuration files:

  • Main Configuration: /etc/csf/csf.conf

  • Allow/Deny Lists: /etc/csf/csf.allow & /etc/csf/csf.deny

๐Ÿ› ๏ธ Whitelisting or Blacklisting IPs/Ports

To allow/block IPs or ports, edit the relevant file and reload CSF:

nano /etc/csf/csf.allow  # Whitelist IPs
nano /etc/csf/csf.deny   # Blacklist IPs
csf -r  # Apply changes

๐Ÿ— Custom Rules in CSF

If you need to define custom firewall rules, always do so within CSF's configuration instead of modifying nftables directly.


๐Ÿ“Š 4๏ธโƒฃ Verifying Active Rules

Even though you shouldn't modify nftables manually, it's useful to review applied rules.

Run the following command to inspect the active ruleset:

nft list ruleset

๐Ÿ” What You'll See:

  • Multiple tables like ip filter, ip raw, and ip mangle.

  • Rules that are maintained by the iptables-nft compatibility layer.


๐Ÿ”ฅ 5๏ธโƒฃ Advantages of Using nftables with CSF

๐Ÿ›ก๏ธ Enhanced Security & Performance

โšก Modern Syntax & Flexibility:

  • Supports sets, maps, and efficient rule processing.

  • Reduces the complexity of firewall configurations.

โœ… CSF Compatibility:

  • CSF seamlessly works with nftables.

  • Allows continued use of familiar CSF commands while leveraging nftables' modern capabilities.

๐ŸŽฏ Streamlined Management

๐Ÿ“Œ Centralized Control:

  • Managing the firewall through CSF configuration files ensures that changes are consistent.

  • Reduces the risk of conflicts with system-managed tables.

๐Ÿ“Œ Reduced Configuration Drift:

  • Prevents accidental overwrites or errors from manual nftables modifications.

  • Ensures that security policies remain correctly enforced.


๐Ÿ Conclusion

Managing CSF firewall rules on CentOS 8 means embracing the nftables framework. Since reverting to iptables-legacy is not an option, administrators should:

๐Ÿ”น Use CSF commands & configuration files for all changes. ๐Ÿ”น Avoid direct modifications to nftables-managed tables. ๐Ÿ”น Verify rule translations using nft list ruleset to ensure security policies are correctly enforced.

By following these best practices, you maintain a secure, high-performance firewall configuration on CentOS 8 while still using the familiar CSF interface. ๐Ÿš€๐Ÿ”ฅ

ย 


Was this answer helpful?

« Back