Add support for masquerading udp and icmp connections.

This commit is contained in:
2021-04-12 18:23:07 +02:00
parent d6cf429736
commit 83a50e5b56
3 changed files with 77 additions and 1 deletions

View File

@ -303,7 +303,7 @@ fi
if [[ ${#no_if_for_ip_arr[@]} -gt 0 ]] ; then
echo_warning
for _ip in ${no_if_for_ip_arr[@]} ; do
warn "Masquerading for ip '$_ip' was omitted - No idestination interface present!"
warn "(TCP) Masquerading for ip '$_ip' was omitted - No destination interface present!"
done
else
echo_done
@ -311,6 +311,43 @@ fi
echo
unset no_if_for_ip_arr
declare -a no_if_for_ip_arr
if [[ ${#masquerade_udp_con_arr[@]} -gt 0 ]] && $kernel_activate_forwarding ; then
for _val in "${masquerade_udp_con_arr[@]}" ; do
IFS=':' read -a _val_arr <<< "${_val}"
# - Skip if no interface is given
# -
if [[ -z "${_val_arr[3]}" ]] ; then
no_if_for_ip_arr+=("${_val_arr[1]}")
continue
fi
$ipt -t nat -A POSTROUTING -o ${_val_arr[3]} -p udp -s ${_val_arr[0]} -d ${_val_arr[1]} --dport ${_val_arr[2]} -j MASQUERADE
done
fi
#echo_done # Flushing firewall iptable (IPv4)..
if [[ ${#no_if_for_ip_arr[@]} -gt 0 ]] ; then
echo_warning
for _ip in ${no_if_for_ip_arr[@]} ; do
warn "(UDP) Masquerading for ip '$_ip' was omitted - No destination interface present!"
done
else
echo_done
fi
echo
if [[ ${#masquerade_icmp_con_arr[@]} -gt 0 ]] && $kernel_activate_forwarding ; then
for _val in "${masquerade_icmp_con_arr[@]}" ; do
IFS=':' read -a _val_arr <<< "${_val}"
$ipt -t nat -A POSTROUTING -p icmp -s ${_val_arr[0]} -d ${_val_arr[1]} -j MASQUERADE
done
fi
# -------------
# - Log given IP Addresses
# -------------