diff --git a/conf/main_ipv4.conf.sample b/conf/main_ipv4.conf.sample index 5bd870e..99c450a 100644 --- a/conf/main_ipv4.conf.sample +++ b/conf/main_ipv4.conf.sample @@ -453,6 +453,31 @@ allow_to_ext_net="" +# ============= +# - Allow gateway itself to local service +# ============= + +# - allow_gw_to_local_service +# - +# - allow_gw_to_local_service=" [local-ip:port:protocol> [.." +# - +# - Allow connections initiated by the gateway itself (OUTPUT chain) to the +# - given service in a local network. Needed e.g. if a reverse proxy (nginx, +# - apache, ..) running on the gateway forwards requests to a local server. +# - +# - Only 'tcp' and 'udp' are allowed values for protocol. A port range +# - can be given as 'from-to'. +# - +# - Example: +# - allow_gw_to_local_service="192.168.10.13:9663:tcp +# - 192.168.10.20:8000-8010:tcp" +# - +# - Blank separated list +# - +allow_gw_to_local_service="" + + + # ============= # --- Separate local Networks # ============= diff --git a/conf/post_decalrations.conf b/conf/post_decalrations.conf index 6c3056e..7341573 100644 --- a/conf/post_decalrations.conf +++ b/conf/post_decalrations.conf @@ -287,6 +287,14 @@ for _val in $allow_to_ext_net ; do allow_to_ext_net_arr+=("$_val") done +# --- +# - Allow gateway itself to local service +# --- +declare -a allow_gw_to_local_service_arr=() +for _val in $allow_gw_to_local_service ; do + allow_gw_to_local_service_arr+=("$_val") +done + # --- # - Separate local Networks # --- diff --git a/ipt-firewall-gateway b/ipt-firewall-gateway index e63fb43..0bd2cb2 100755 --- a/ipt-firewall-gateway +++ b/ipt-firewall-gateway @@ -2708,6 +2708,35 @@ fi +# --- +# - Allow gateway itself to local service +# --- + +echononl "\tAllow gateway itself to local service" + +if [[ ${#allow_gw_to_local_service_arr[@]} -gt 0 ]] ; then + + for _val in "${allow_gw_to_local_service_arr[@]}" ; do + + IFS=':' read -a _val_arr <<< "${_val}" + + if [[ "${_val_arr[1]}" == *"-"* ]]; then + _port="${_val_arr[1]//-/:}" + else + _port=${_val_arr[1]} + fi + + $ipt -A OUTPUT -p ${_val_arr[2]} -d ${_val_arr[0]} --dport ${_port} -m conntrack --ctstate NEW -j ACCEPT + + done + + echo_done +else + echo_skipped +fi + + + # --- # - Separate local networks # ---