---
title: 'External Pre and Post Scripts'
url: 'https://docs.danami.com/juggernaut/user-guide/external-pre-and-post-scripts'
markdown: 'https://docs.danami.com/juggernaut/user-guide/external-pre-and-post-scripts.md'
date: '2026-09-22'
description: 'External commands can be run before or after CSF sets up the iptables chains and rules (e.g. iptables rules not covered by CSF). Pre Script To run external commands before CSF configures iptables create the file: /usr/local/csf/bin/csfpre.sh Add an appropriate shebang interpreter line and then what…'
taxonomy:
  category:
    - docs
  tag:
    - csf
---

[](#)  [ Basics ](https://docs.danami.com/juggernaut/)     [ User Guide ](https://docs.danami.com/juggernaut/user-guide)      External Pre and Post Scripts    

# External Pre and Post Scripts

External commands can be run before or after CSF sets up the iptables chains and rules (e.g. iptables rules not covered by CSF).

## Pre Script

To run external commands **before** CSF configures iptables create the file:

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

Add an appropriate shebang interpreter line and then whatever external commands you wish to execute:

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

Set that file as executable:

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

## Post Script

To run external commands **after** CSF configures iptables create the file:

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

Add an appropriate shebang interpreter line and then whatever external commands you wish to execute:

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

Set that file as executable:

```
chmod +x /usr/local/csf/bin/csfpost.sh
```

## Related Files

| File | Description |
|---|---|
| `/usr/local/csf/bin/csfpre.sh` | Commands to run **before** CSF sets up the iptables chains and rules. (file must be created) |
| `/usr/local/csf/bin/csfpost.sh` | Commands to run **after** CSF sets up the iptables chains and rules. (file must be created) |

## Related Pages

- [Watching IP Addresses](https://docs.danami.com/juggernaut/user-guide/watching-ip-addresses "Watching IP Addresses")
- [Firewall](https://docs.danami.com/juggernaut/user-guide/firewall "Firewall")
- [Port / IP Redirection](https://docs.danami.com/juggernaut/user-guide/port-ip-redirection "Port / IP Redirection")
- [Disable Server IP Addresses](https://docs.danami.com/juggernaut/user-guide/disable-server-ip-addresses "Disable Server IP Addresses")
- [Binary Locations](https://docs.danami.com/juggernaut/settings/other/binary-locations "Binary Locations")

 [ ](https://docs.danami.com/juggernaut/user-guide/firewall) [](https://docs.danami.com/juggernaut/user-guide/watching-ip-addresses)

---

## Navigation

- Parent: [User Guide](https://docs.danami.com/juggernaut/user-guide.md)
- Previous: [Port Flood Protection](https://docs.danami.com/juggernaut/user-guide/port-flood-protection.md)
- Next: [LFD Clustering](https://docs.danami.com/juggernaut/user-guide/lfd-clustering.md)
