When you are using a customized kernel, which you have built it is likely that enabling ufw firewall does not always work as intended.
More specifically, you are likely to encounter the following error when you type ufw enable as a root or a sudo:
ERROR: problem running ufw-init
What the error means is that the command enable cannot be executed at that given time. Ufw can however be enabled with an easy workaround, which is presented below. You need to be a root or a sudo for the below steps to succeed.
In a terminal client copy and paste the following lines:
echo ”
#enable on startup
ENABLED=yes” >> /etc/default/ufw
The above tells ufw configuration file to enable it upon system startup. The step is basically the same as ufw enable but without any errors. You can test if the workaround works for you by rebooting your computer and then executing as a root or a sudo:
ufw disable #To disable the firewall
ufw enable #To reload the firewall, this should still produce the ufw-init error
ufw status verbose #To verify the status of the firewall.
Even when the second command ufw enable should still produce the ufw-init error the third command should produce something like below:
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing)
New profiles: skip
If the above is the case then congratulations your ufw firewall should be working with your custom built kernel.
Note. Even when rebooting the computer might not be needed, I do find it a good route to undertake when verifying ufw functionality. The previous is since if there are any startup errors you will certainly see them.