Articles on: VPS Hosting

How to access the firewall on a Linux VPS

Step-by-Step Guide: Accessing and Managing Firewall on a Linux VPS using ufw

To access and manage the firewall on your Linux VPS, you can utilize "iptables" or the more user-friendly frontend, "ufw" (Uncomplicated Firewall). Here's a step-by-step guide for handling the firewall with ufw:

Step 1: Connect to Your Linux VPS
- Utilize SSH or any other remote access method to establish a connection to your Linux VPS.

Step 2: Log In to Your VPS
- Open a terminal or SSH client and log in to your VPS using your login credentials.

Step 3: Check for ufw Installation
- To verify if ufw is installed, execute the following command:
sudo ufw status
If ufw is not installed, you can install it with the following commands:
sudo apt update
sudo apt install ufw


Step 4: Enable ufw
- Once ufw is installed, enable it with the command:

sudo ufw enable

Note: Enabling ufw may momentarily interrupt your SSH connection. Ensure you have an alternative means of accessing your VPS in case of disconnection.

Step 5: Allow Incoming Connections to Specific Ports
- To permit incoming connections to a specific port, use the command:

sudo ufw allow <port_number>

Replace <port_number> with the desired port (e.g., 80 for HTTP).
To specify a protocol (e.g., TCP or UDP), add it after the port number:
sudo ufw allow 22/tcp


Step 6: Deny Incoming Connections on Specific Ports
- To reject incoming connections on a specific port, use the command:
sudo ufw deny <port_number>


Step 7: Check ufw Status and Firewall Rules
- Examine the current firewall rules and ufw status with the command:
sudo ufw status verbose


Step 8: Modify or Delete Existing Rules
- You can adjust or remove existing rules using ufw commands. For more advanced configuration options, consult the ufw documentation or run man ufw.

Remember to exercise caution when configuring the firewall to prevent unintentional blocking of essential connections or exposing your VPS to security risks. Thoroughly review and test your firewall rules for best practices.

Updated on: 27/10/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!