---
title: Ensure ufw Default Policy for Routed (Forwarded) Traffic is Disabled
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > Ensure ufw Default Policy for Routed
  (Forwarded) Traffic is Disabled
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Ensure ufw Default Policy for Routed (Forwarded) Traffic is Disabled
 
## Description{% #description %}

The default policy for routed (forwarded) traffic in ufw should be set to disabled or deny, ensuring that the system does not forward packets between interfaces unless explicitly configured to do so.

## Rationale{% #rationale %}

Unless the system is intended to act as a router, forwarding traffic between network interfaces should be disabled. Disabling the routed default policy prevents the system from accidentally or maliciously forwarding traffic.

## Remediation{% #remediation %}

### Shell script{% #shell-script %}

The following script can be run on the host to remediate the issue.

```bash
#!/bin/bash

# Remediation is applicable only in certain platforms
if dpkg-query --show --showformat='${db:Status-Status}' 'linux-base' 2>/dev/null | grep -q '^installed$' && { dpkg-query --show --showformat='${db:Status-Status}' 'ufw' 2>/dev/null | grep -q '^installed$'; }; then

ufw default deny routed

else
    >&2 echo 'Remediation is not applicable, nothing was done'
fi
```

## Warning{% #warning %}

Changing firewall settings while connected over network can result in being locked out of the system.
