Compare commits

..

2 commits

Author SHA1 Message Date
Oracle Public Cloud User
c00468eaea added caddy redirections 2024-02-14 18:19:50 +00:00
Oracle Public Cloud User
03290d7a8d don't reload firewall-cmd until all commands are added/deleted 2024-02-14 18:19:40 +00:00
2 changed files with 9 additions and 2 deletions

View file

@ -13,6 +13,13 @@ RULES=(
"443:4430"
"443:4430/udp"
"22:22"
"3478:3478"
"3478:3478/udp"
"25:2500"
"143:1430"
"465:4650"
"587:5870"
"993:9930"
)
# Runs the actual script

View file

@ -14,7 +14,6 @@ add_NAT_forwarding() {
forward_to_port="$6"
firewall-cmd --add-rich-rule "rule family=\"ipv4\" destination address=\"$original_destination_ip\" forward-port port=\"$original_destination_port\" protocol=\"$tcp_or_udp\" to-addr=\"$forward_to_ip\" to-port=\"$forward_to_port\"" --permanent > /dev/null
firewall-cmd --reload > /dev/null
echo "+ [$interface_source][$tcp_or_udp] $original_destination_ip:$original_destination_port --> $forward_to_ip:$forward_to_port"
}
@ -33,7 +32,6 @@ remove_NAT_forwarding() {
forward_to_port="$6"
firewall-cmd --remove-rich-rule "rule family=\"ipv4\" destination address=\"$original_destination_ip\" forward-port port=\"$original_destination_port\" protocol=\"$tcp_or_udp\" to-addr=\"$forward_to_ip\" to-port=\"$forward_to_port\"" --permanent > /dev/null
firewall-cmd --reload > /dev/null
echo "- [$interface_source][$tcp_or_udp] $original_destination_ip:$original_destination_port --> $forward_to_ip:$forward_to_port"
}
@ -78,4 +76,6 @@ for rule in "${RULES[@]}"; do
esac
done
firewall-cmd --reload > /dev/null
echo -e "\nDone! Don't forget to add/remove the rules in the security list."