How To Install/Add Custom iptables Rules in CSF?

How To Install/Add Custom iptables Rules in CSF?

What is iptables?

Iptables is an application program that makes it possible for the system administrator to configure the tables provided by the Linux Kernel Firewall and the chains and rules it stores. Different different Linux Kernel Modules and Programs are now days used for different kind of protocols iptablesapplies to Ipv4, ip6tables to Ipv6, arptables to ARP, and ebtables to Ethernet frames.

What is CSF (ConfigServer Firewall)?

“CSF” stands for ConfigServer Firewall. It's a Firewall that based on iptables. The basic work of CSF ( ConfigServer Firewall) is to make it easier to implement the iptables rules. There are some times need to Install or Add Some Custom rules in iptables rules.

How To Install/Add Custom iptables Rules in CSF (ConfigServer Firewall)?

First of all install Proper CSF Version on your Linux System. CSF offers pre and post scripts which can be executed before and after CSF Rules. External commands (e.g. iptables rules not covered by csf) can be run before and/or after csf sets up the iptables chains and rules.

1. To run external commands before csf configures iptables create the file:

/usr/local/csf/bin/csfpre.sh

Set that file as executable and add an appropriate shebang interpreter line and then whatever external commands you wish to execute.

For example:

#!/bin/sh
/some/path/to/binary -a -b -c etc


Then chmod +x /usr/local/csf/bin/csfpre.sh

2. To run external commands after csf configures iptables create the file:

/usr/local/csf/bin/csfpost.sh

Set that file as executable and add an appropriate shebang interpreter line and then whatever external commands you wish to execute.

Note: The scripts can alternatively be placed in /etc/csf/. If a script is found in both locations (/etc/csf/ and /usr/local/csf/bin/) then only the script in /usr/local/csf/bin/ will be executed and You MUST use the full path to any binaries that you execute within these scripts.
Author
bhawanisingh
Views
3,000
First release
Last update
Rating
0.00 star(s) 0 ratings
Top