added SNAT to use the correct outgoing IP address from Oracle depending on the WireGuard host

This commit is contained in:
Oracle Public Cloud User 2024-02-15 09:32:45 +00:00
parent c00468eaea
commit f0542a25c1

View file

@ -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."