From f0542a25c11337576e0e3ade8af8a9b84b17a171 Mon Sep 17 00:00:00 2001 From: Oracle Public Cloud User Date: Thu, 15 Feb 2024 09:32:45 +0000 Subject: [PATCH] added SNAT to use the correct outgoing IP address from Oracle depending on the WireGuard host --- configure_NAT_from_RULES | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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."