When working on your server you might need to disable the Uncomplicated Firewall (UFW). When doing so you’ll notice it doesn’t display your rules when the application is inactive.
# ufw status Status: inactive
To get around this you have to find the UFW users file (file name == user.rules). Every installation is different, the fastest way to find this file is to use the FIND command.
# find / -name user.rules /etc/ufw/user.rules
Now open the file, you are looking for this section: ### RULES ###. Here is an example of what my file looks like:
### tuple ### allow any 22 0.0.0.0/0 any [my ip] in
-A ufw-user-input -p tcp --dport 22 -s [my ip] -j ACCEPT
-A ufw-user-input -p udp --dport 22 -s [my ip] -j ACCEPT
### tuple ### allow any 443 0.0.0.0/0 any [my ip] in
-A ufw-user-input -p tcp --dport 443 -s [my ip] -j ACCEPT
-A ufw-user-input -p udp --dport 443 -s [my ip] -j ACCEPT
You’ll notice the format, it shows the main port and associated IP then highlights the specific connection protocols allowed on the port (e.g., TCP and UDP).