File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed
linux_os/guide/system/network/network-iptables/iptables_activation/set_loopback_traffic/sce Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change 1- #! /bin/bash
1+ #! /usr/ bin/env bash
22# platform = multi_platform_sle,multi_platform_ubuntu
33# check-import = stdout
44
5- regex=" \s+[0-9]+\s+[0-9]+\s+ACCEPT\s+all\s+--\s+lo\s+\*\s+0\.0\.0\.0\/0\s+0\.0\.0\.0\/0[[:space:]]+[0-9]+\s+[0-9]+\s+DROP\s+all\s+--\s+\*\s+\*\s+127\.0\.0\.0\/8\s+0\.0\.0\.0\/0"
5+ # Check that iptables exist in current path
6+ if ! command -v iptables > /dev/null; then
7+ exit " $XCCDF_RESULT_FAIL "
8+ fi
69
7- # Check chain INPUT for loopback related rules
8- if ! iptables -L INPUT -v -n -x | grep -Ezq " $regex " ; then
10+ # Get current rules
11+ rules=$( iptables -S)
12+
13+ # Check for "-A INPUT -i lo -j ACCEPT"
14+ if [[ ! " $rules " =~ " -A INPUT -i lo -j ACCEPT" ]]; then
915 exit " $XCCDF_RESULT_FAIL "
1016fi
1117
12- # Check chain OUTPUT for loopback related rules
13- if ! iptables -L OUTPUT -v -n -x | grep -Eq " \s[0-9]+\s+[0-9]+\s+ACCEPT\s+all\s+--\s+\*\s+lo\s+0\.0\.0\.0\/0\s+0\.0\.0\.0\/0" ; then
18+ # Check for "-A OUTPUT -o lo -j ACCEPT"
19+ if [[ ! " $rules " =~ " -A OUTPUT -o lo -j ACCEPT" ]]; then
20+ exit " $XCCDF_RESULT_FAIL "
21+ fi
22+
23+ # Check for "-A INPUT -s 127.0.0.0/8 -j DROP"
24+ if [[ ! " $rules " =~ " -A INPUT -s 127.0.0.0/8 -j DROP" ]]; then
1425 exit " $XCCDF_RESULT_FAIL "
1526fi
1627
1728exit " $XCCDF_RESULT_PASS "
29+
You can’t perform that action at this time.
0 commit comments