How to add NAT iptables rules with CSF

32 sec read

What is CSF

Config Server Firewall (or CSF) is a free and advanced firewall for most Linux distributions.

How to add NAT iptables rules with CSF Firewall

We can add custom NAT iptables rules in /etc/csf/ OR/AND /etc/csf/
0. Create or

touch /etc/csf/ /etc/csf/

1. Change permission to make the script executable

chmod +x /etc/csf/ /etc/csf/
chmod +t /etc/csf/ /etc/csf/

2. Add NAT iptables rules

vim /etc/csf/

add iptables rules like this:

iptables -t nat -F
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination
iptables -t nat -A POSTROUTING -p tcp -d --dport 80 -j SNAT --to-source

3. Restart csf and check the result

csf -r
iptables -t nat -L


+ Google
+ TecAdmin

Reset root password on CentOS 7

Edit boot menu on-the-go 0. reboot the CentOS 7 and press ESC when GRUB menu show up on the screen and press “e”1. find...
18 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *