Restoring CSF (ConfigServer Security & Firewall) configuration from a backup is a straightforward process. Follow these steps to restore your CSF firewall configuration:
Steps to Restoring CSF Firewall Configuration from Backup
- Locate the Backup File
- Typically, a backup file is a copy of your csf.conf file, which is the main configuration file for CSF.
- Backup locations may vary, but they are often stored in the same directory where the original file is located, like /etc/csf/. The backup might have been manually created by copying the csf.conf file.
/etc/csf/csf.conf.bak
Stop the CSF Firewall (Optional) It’s a good idea to stop the firewall before restoring configuration changes to avoid conflicts or incorrect behavior.
csf -x
Restore the Backup You can restore the backup by copying the backup file over the original csf.conf file.
cp /etc/csf/csf.conf.bak /etc/csf/csf.conf
- Ensure you have the correct permissions to write over the original file. You might need to use sudo if you’re not logged in as the root user.
- Verify Configuration (Optional) After restoring the configuration, you may want to verify that the settings are correct by checking the csf.conf file.
vi /etc/csf/csf.conf
Or you can use cat to display the file content:
cat /etc/csf/csf.conf
Restart the CSF Firewall Once the backup has been restored, restart CSF to apply the new configuration.
csf -r
- The -r option will reload CSF with the new configuration.
Start CSF and LFD (If Stopped) If you stopped the CSF or the LFD (Login Failure Daemon) earlier, you should start them again:
csf -e # Enable CSF
service lfd restart # Restart LFD
Check CSF Status After the restore, you can verify that CSF is running and functioning as expected:
csf -v # Check the version
csf -s # Check the current status
Create a Backup Before Overwriting: If you’re restoring a backup, it’s a good idea to back up the current csf.conf just in case:
cp /etc/csf/csf.conf /etc/csf/csf.conf.backup
Ensure Correct Permissions: After restoring, make sure that the csf.conf file has the correct file permissions, which are usually 600:
chmod 600 /etc/csf/csf.conf
By following these steps, you will successfully restore your CSF configuration from a backup. Let me know if you need further assistance!
Restoring CSF in WHM
- Log into WHM and navigate to the ConfigServer Firewall (CSF) plugin.
- From the CSF home page, scroll down to the Firewall Profiles button
Click the Firewall Profiles button to open the profile.
Scroll down to the Restore Backup Of csf.conf section.
Select the backup you created, and click Restore Backup.
Once the backup is complete, restart csf and lfd.
I believe the above article will explained about CSF restoration process. To how WHM/cPanel redirecting to hostname click here.