---
title: Verify iptables Enabled
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > Datadog Security > OOTB Rules > Verify iptables Enabled
---

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

# Verify iptables Enabled
 
## Description{% #description %}

The `iptables` service can be enabled with the following command:

```
$ sudo systemctl enable iptables.service
```

## Rationale{% #rationale %}

The `iptables` service provides the system's host-based firewalling capability for IPv4 and ICMP.

## 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 ( ( { rpm --quiet -q iptables-services && { systemctl is-enabled iptables.service 2>/dev/null | grep -q '^enabled' || systemctl is-enabled ip6tables.service 2>/dev/null | grep -q '^enabled'; }; } && rpm --quiet -q kernel ) ); then

SYSTEMCTL_EXEC='/usr/bin/systemctl'
"$SYSTEMCTL_EXEC" unmask 'iptables.service'
if [[ $("$SYSTEMCTL_EXEC" is-system-running) != "offline" ]]; then
  "$SYSTEMCTL_EXEC" start 'iptables.service'
fi
"$SYSTEMCTL_EXEC" enable 'iptables.service'

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

### Ansible playbook{% #ansible-playbook %}

The following playbook can be run with Ansible to remediate the issue.

```go
- name: Gather the package facts
  package_facts:
    manager: auto
  tags:
  - CCE-87026-1
  - NIST-800-53-AC-4
  - NIST-800-53-CA-3(5)
  - NIST-800-53-CM-6(a)
  - NIST-800-53-CM-7(b)
  - NIST-800-53-SC-7(21)
  - enable_strategy
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
  - service_iptables_enabled

- name: Gather the service facts
  ansible.builtin.service_facts: null
  tags:
  - CCE-87026-1
  - NIST-800-53-AC-4
  - NIST-800-53-CA-3(5)
  - NIST-800-53-CM-6(a)
  - NIST-800-53-CM-7(b)
  - NIST-800-53-SC-7(21)
  - enable_strategy
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
  - service_iptables_enabled

- name: Verify iptables Enabled - Enable service iptables
  block:

  - name: Gather the package facts
    ansible.builtin.package_facts:
      manager: auto

  - name: Verify iptables Enabled - Enable Service iptables
    ansible.builtin.systemd:
      name: iptables
      enabled: true
      state: started
      masked: false
    when:
    - '"iptables-services" in ansible_facts.packages'
  tags:
  - CCE-87026-1
  - NIST-800-53-AC-4
  - NIST-800-53-CA-3(5)
  - NIST-800-53-CM-6(a)
  - NIST-800-53-CM-7(b)
  - NIST-800-53-SC-7(21)
  - enable_strategy
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
  - service_iptables_enabled
  - special_service_block
  when: ( ("iptables-services" in ansible_facts.packages and ((((ansible_facts.services
    | default({}))["iptables.service"] | default({})).status | default("")) in ["enabled",
    "enabled-runtime"] or (((ansible_facts.services | default({}))["ip6tables.service"]
    | default({})).status | default("")) in ["enabled", "enabled-runtime"])) and "kernel"
    in ansible_facts.packages )
```
