# Enabling UFW and Setting Up Firewall Rules

1. **Enable UFW:**
    
    To enable UFW, use the following command:
    
    ```apache
    sudo ufw enable
    ```
    
    After running this command, UFW will be active, and the default policy will be to deny all incoming connections.
    
2. **Allow Specific Services or Ports:**
    
    You can allow specific services or ports by using UFW. For example, to allow incoming SSH connections (port 22), you can use the following command:
    
    ```apache
    sudo ufw allow ssh
    ```
    
    If you want to allow other services, replace `ssh` with the service name (e.g., `http`, `https`, `ftp`, etc.) or the port number you want to allow.
    
3. **Check UFW Status:**
    
    After setting up your rules, you can check the status to ensure everything is configured correctly:
    
    ```apache
    sudo ufw status
    ```
    
    It should display your active rules.
    
4. **Configure Outbound Connections (Optional):**
    
    UFW by default allows all outbound connections. If you want to restrict outbound connections, you can set specific rules for outbound traffic. For example, to deny outgoing connections on port 80 (HTTP), you can use:
    
    ```apache
    sudo ufw deny out 80
    ```
    
    Replace `80` with the port number you want to restrict.
    
5. **Other Useful Commands:**
    
    * To delete a rule: `sudo ufw delete <rule>`
        
    * To disable UFW: `sudo ufw disable`
