Install iptables-services Package

Description

The iptables-services package can be installed with the following command:

$ sudo yum install iptables-services

Rationale

iptables-services provides the services iptables and ip6tables that have been split out of the base package since they are not active by default anymore. These services load the iptables rules during the system startup and also allow one to reload the iptables rules during runtime.

Remediation

Shell script

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

#!/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'; }; } ); then

if ! rpm -q --quiet "iptables-services" ; then
    yum install -y "iptables-services"
fi

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

Ansible playbook

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

- name: Gather the package facts
  package_facts:
    manager: auto
  tags:
  - NIST-800-53-CM-6(a)
  - enable_strategy
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
  - package_iptables-services_installed

- name: Gather the service facts
  ansible.builtin.service_facts: null
  tags:
  - NIST-800-53-CM-6(a)
  - enable_strategy
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
  - package_iptables-services_installed

- name: Ensure iptables-services is installed
  ansible.builtin.package:
    name: iptables-services
    state: present
  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"]))
  tags:
  - NIST-800-53-CM-6(a)
  - enable_strategy
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
  - package_iptables-services_installed