#!/usr/bin/env bash

kernel_parameters=("net.ipv4.conf.all.rp_filter" "net.ipv4.conf.default.rp_filter")
kernel_values=("1" "1")
len=${#kernel_parameters[@]}
for ((i = 0; i < len; i++)); do
	param=${kernel_parameters[$i]}
	value=${kernel_values[$i]}
	current_value=$(sysctl -n "$param" 2>/dev/null)

	# Check if sysctl command was successful
	if [ $? -ne 0 ]; then
		echo "Error: Kernel parameter $param does not exist or could not be retrieved."
		exit 1
	fi

	# Check if the current value matches the expected value
	if [ "$current_value" == "$value" ]; then
		echo "Kernel parameter $param is set correctly to $value."
	else
		echo "Kernel parameter $param is not set to $value (current value: $current_value)."
		exit 1
	fi
done
