Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

On the source server, export the current firewall rules using the following command:

sudo ufw export > ufw-rules

This command saves the current firewall rules in a file named ``ufw-rules``` in the current directory.

Transfer the ufw-rules file to the destination server. You can use any method to transfer the file, such as SCP, FTP, or SFTP.

On the destination server, import the firewall rules from the "ufw-rules" file using the following command:

sudo ufw import < ufw-rules

This command imports the firewall rules from the ufw-rules file.

Verify that the firewall rules have been successfully migrated by running the following command on the destination server:

sudo ufw status

This command lists all the firewall rules, and you should see the same rules as on the source server.

Note: The UFW export/import feature is available from UFW version 0.36 and above. If you are using an older version of UFW, you can manually copy the "/etc/ufw" directory from the source server to the destination server. This directory contains all the UFW configuration files, including the firewall rules. However, this method is not recommended as it can overwrite existing UFW configuration files on the destination server.