The fpfwd and fpfw scripts are designed to manage IP blocking based on fingerprints generated by the muonfp tool. These scripts use SQLite to store and manage fingerprints and associated IP addresses, and nftables to enforce IP blocking rules.
- fpfwd: This script runs as a daemon, continuously monitoring for changes in fingerprints and updating
nftablesrules accordingly. - fpfw: This script provides a command-line interface to add or remove fingerprints, show currently blocked fingerprints, and flush all
nftablesrules.
These scripts require the muonfp tool, which can be found at sundruid/muonfp.
Before running the scripts, ensure the following configurations are set correctly in both scripts:
PART_FILE_DIRECTORY: Directory containing the.partfiles generated bymuonfp.LOG_FILE: Log file for script activity.POLL_INTERVAL: Polling interval in seconds for thefpfwdscript.DATABASE_FILE: SQLite database file used by both scripts.
The fpfwd script runs as a daemon and performs the following tasks:
- Sets up the SQLite database and creates necessary tables.
- Reconciles
nftablesrules with the database. - Processes fingerprint changes and updates
nftablesrules. - Processes fingerprint removals and removes associated IP addresses from
nftables.
To run the fpfwd script, use the following command:
The fpfw script provides a command-line interface to manage fingerprints and nftables rules. It supports the following commands:
add <fingerprint>: Add a fingerprint to be blocked.remove <fingerprint>: Remove a fingerprint from being blocked.show: Show all unique fingerprints currently being blocked.flush: Flush allnftablesrules and clear the database.-h, --help: Show the help message and exit.
To use the fpfw script, use the following command format:
./fpfwd.py
The fpfw script provides a command-line interface to manage fingerprints and nftables rules. It supports the following commands:
add <fingerprint>: Add a fingerprint to be blocked.remove <fingerprint>: Remove a fingerprint from being blocked.show: Show all unique fingerprints currently being blocked.flush: Flush allnftablesrules and clear the database.-h, --help: Show the help message and exit.
To use the fpfw script, use the following command format:
./fpfw.py [fingerprint]
-
Add a fingerprint:
./fpfw.py add <fingerprint>
-
Remove a fingerprint:
./fpfw.py remove <fingerprint>
-
Show currently blocked fingerprints:
./fpfw.py show
-
Flush all
nftablesrules and clear the database:./fpfw.py flush
Both scripts log their activities to the specified log file (fpfwd.log by default). Ensure the log file path is writable by the user running the scripts.
These scripts are provided under the MIT License. See the LICENSE file for more information.
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
If you encounter any issues or have questions, please open an issue on the GitHub repository.
