diff --git a/configure_NAT_from_RULES b/configure_NAT_from_RULES index 7516f28..66aa34f 100755 --- a/configure_NAT_from_RULES +++ b/configure_NAT_from_RULES @@ -76,6 +76,18 @@ for rule in "${RULES[@]}"; do esac done +case "$action" in + "up") + firewall-cmd --permanent --direct --add-rule ipv4 nat POSTROUTING 0 -o "$INTERFACE_SOURCE" -s "$FORWARD_TO_IP" -j SNAT --to-source "$ORIGINAL_DESTINATION_IP" + ;; + "down") + firewall-cmd --permanent --direct --remove-rule ipv4 nat POSTROUTING 0 -o "$INTERFACE_SOURCE" -s "$FORWARD_TO_IP" -j SNAT --to-source "$ORIGINAL_DESTINATION_IP" + ;; + *) + echo "Invalid action. Use 'up' or 'down'." + exit 1 + ;; + firewall-cmd --reload > /dev/null echo -e "\nDone! Don't forget to add/remove the rules in the security list."