allow_all_ext_traffic_to_local_service: accept extern interface instead of address.
If an extern interface (e.g. $ext_if_static_1) is given as first field, only an INPUT rule for traffic to the gateway itself on that interface is created - no address lookup needed. Implemented for IPv4 and IPv6. Also: - ip6t-firewall-gateway: check gateway_ipv6_address_arr (was gateway_ipv4_address_arr) when detecting own gateway addresses. - main_ipv*.conf.sample: document how to allow incoming traffic for a reverse proxy in 'allow_gw_to_local_service', fix example parameter name of 'allow_all_ext_traffic_to_local_service'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
954dce1bf0
commit
a57980f3f2
4 files changed
+77
-7
No files matched your search
@@ -104,6 +104,11 @@ any_access_from_inet_networks=""
|
|||||||
# -
|
# -
|
||||||
# - allow_all_ext_traffic_to_local_service="local-address:port:protocol [local-address:port:protocol] .."
|
# - allow_all_ext_traffic_to_local_service="local-address:port:protocol [local-address:port:protocol] .."
|
||||||
# -
|
# -
|
||||||
|
# - Instead of 'local-address' an extern interface (e.g. $ext_if_static_1) can
|
||||||
|
# - be given. Then traffic coming in on that interface to the given port of the
|
||||||
|
# - gateway itself is allowed (INPUT chain, no address needed). Useful e.g. if
|
||||||
|
# - the gateway acts as reverse proxy (see also 'allow_gw_to_local_service').
|
||||||
|
# -
|
||||||
# - Note:
|
# - Note:
|
||||||
# - =====
|
# - =====
|
||||||
# - - Only 'tcp' and 'udp' are allowed valuse for protocol.
|
# - - Only 'tcp' and 'udp' are allowed valuse for protocol.
|
||||||
@@ -111,10 +116,12 @@ any_access_from_inet_networks=""
|
|||||||
# - Example:
|
# - Example:
|
||||||
# - allow extern traffic to service at 83.223.73.210 on port 1036
|
# - allow extern traffic to service at 83.223.73.210 on port 1036
|
||||||
# - allow extern traffic to https service at 83.223.73.204
|
# - allow extern traffic to https service at 83.223.73.204
|
||||||
|
# - allow extern traffic on interface $ext_if_static_1 to port 9443 of the gateway
|
||||||
# -
|
# -
|
||||||
# - allow_ext_net_to_local_service="
|
# - allow_all_ext_traffic_to_local_service="
|
||||||
# - 83.223.73.210:1036:tcp
|
# - 83.223.73.210:1036:tcp
|
||||||
# - 83.223.73.204:$standard_https_port:tcp
|
# - 83.223.73.204:$standard_https_port:tcp
|
||||||
|
# - $ext_if_static_1:9443:tcp
|
||||||
# - "
|
# - "
|
||||||
# -
|
# -
|
||||||
# - Blank separated list
|
# - Blank separated list
|
||||||
@@ -470,13 +477,33 @@ allow_to_ext_net=""
|
|||||||
# - connection from the gateway to the local service is dropped by the OUTPUT
|
# - connection from the gateway to the local service is dropped by the OUTPUT
|
||||||
# - chain and the reverse proxy answers with '502 Bad Gateway'.
|
# - chain and the reverse proxy answers with '502 Bad Gateway'.
|
||||||
# -
|
# -
|
||||||
# - Note: Incoming traffic to the reverse proxy on the gateway itself (e.g. port
|
# - Note: This parameter only covers the connection gateway -> local server.
|
||||||
# - 443) must be allowed separately.
|
# - Incoming traffic to the reverse proxy on the gateway itself must be
|
||||||
|
# - allowed separately:
|
||||||
|
# -
|
||||||
|
# - - Standard ports (80/443): set 'local_http_service=true'.
|
||||||
|
# -
|
||||||
|
# - - Any other port (e.g. 9443): use parameter
|
||||||
|
# - 'allow_all_ext_traffic_to_local_service' with the extern interface,
|
||||||
|
# - so that the port is only opened on that interface:
|
||||||
|
# -
|
||||||
|
# - allow_all_ext_traffic_to_local_service="$ext_if_static_1:9443:tcp"
|
||||||
|
# -
|
||||||
|
# - Do NOT add such a port to 'http_ports': that parameter is used in
|
||||||
|
# - many rules (FORWARD to local web servers, ..) and would open the
|
||||||
|
# - port far beyond what is needed.
|
||||||
# -
|
# -
|
||||||
# - Only 'tcp' and 'udp' are allowed values for protocol. A port range
|
# - Only 'tcp' and 'udp' are allowed values for protocol. A port range
|
||||||
# - can be given as 'from-to'.
|
# - can be given as 'from-to'.
|
||||||
# -
|
# -
|
||||||
# - Example:
|
# - Example:
|
||||||
|
# - nginx on the gateway listens on port 9443 and forwards requests to
|
||||||
|
# - http://192.168.10.13:9663:
|
||||||
|
# -
|
||||||
|
# - allow_all_ext_traffic_to_local_service="$ext_if_static_1:9443:tcp"
|
||||||
|
# - allow_gw_to_local_service="192.168.10.13:9663:tcp"
|
||||||
|
# -
|
||||||
|
# - Further example with a port range:
|
||||||
# - allow_gw_to_local_service="192.168.10.13:9663:tcp
|
# - allow_gw_to_local_service="192.168.10.13:9663:tcp
|
||||||
# - 192.168.10.20:8000-8010:tcp"
|
# - 192.168.10.20:8000-8010:tcp"
|
||||||
# -
|
# -
|
||||||
|
|||||||
@@ -101,6 +101,11 @@ any_access_from_inet_networks=""
|
|||||||
# -
|
# -
|
||||||
# - allow_all_ext_traffic_to_local_service="local-address,port,protocol [local-address,port,protocol] .."
|
# - allow_all_ext_traffic_to_local_service="local-address,port,protocol [local-address,port,protocol] .."
|
||||||
# -
|
# -
|
||||||
|
# - Instead of 'local-address' an extern interface (e.g. $ext_if_static_1) can
|
||||||
|
# - be given. Then traffic coming in on that interface to the given port of the
|
||||||
|
# - gateway itself is allowed (INPUT chain, no address needed). Useful e.g. if
|
||||||
|
# - the gateway acts as reverse proxy (see also 'allow_gw_to_local_service').
|
||||||
|
# -
|
||||||
# - Note:
|
# - Note:
|
||||||
# - =====
|
# - =====
|
||||||
# - - Only 'tcp' and 'udp' are allowed valuse for protocol.
|
# - - Only 'tcp' and 'udp' are allowed valuse for protocol.
|
||||||
@@ -108,10 +113,12 @@ any_access_from_inet_networks=""
|
|||||||
# - Example:
|
# - Example:
|
||||||
# - allow extern traffic to service at 2a01:30:1fff:fd00::210 on port 1036
|
# - allow extern traffic to service at 2a01:30:1fff:fd00::210 on port 1036
|
||||||
# - allow extern traffic to https service at 2a01:30:1fff:fd00::204
|
# - allow extern traffic to https service at 2a01:30:1fff:fd00::204
|
||||||
|
# - allow extern traffic on interface $ext_if_static_1 to port 9443 of the gateway
|
||||||
# -
|
# -
|
||||||
# - allow_ext_net_to_local_service="
|
# - allow_all_ext_traffic_to_local_service="
|
||||||
# - 2a01:30:1fff:fd00::210,1036,tcp
|
# - 2a01:30:1fff:fd00::210,1036,tcp
|
||||||
# - 2a01:30:1fff:fd00::204,$standard_https_port,tcp
|
# - 2a01:30:1fff:fd00::204,$standard_https_port,tcp
|
||||||
|
# - $ext_if_static_1,9443,tcp
|
||||||
# - "
|
# - "
|
||||||
# -
|
# -
|
||||||
# - Blank separated list
|
# - Blank separated list
|
||||||
@@ -457,8 +464,21 @@ allow_to_ext_net=""
|
|||||||
# - connection from the gateway to the local service is dropped by the OUTPUT
|
# - connection from the gateway to the local service is dropped by the OUTPUT
|
||||||
# - chain and the reverse proxy answers with '502 Bad Gateway'.
|
# - chain and the reverse proxy answers with '502 Bad Gateway'.
|
||||||
# -
|
# -
|
||||||
# - Note: Incoming traffic to the reverse proxy on the gateway itself (e.g. port
|
# - Note: This parameter only covers the connection gateway -> local server.
|
||||||
# - 443) must be allowed separately.
|
# - Incoming traffic to the reverse proxy on the gateway itself must be
|
||||||
|
# - allowed separately:
|
||||||
|
# -
|
||||||
|
# - - Standard ports (80/443): set 'local_http_service=true'.
|
||||||
|
# -
|
||||||
|
# - - Any other port (e.g. 9443): use parameter
|
||||||
|
# - 'allow_all_ext_traffic_to_local_service' with the extern interface,
|
||||||
|
# - so that the port is only opened on that interface:
|
||||||
|
# -
|
||||||
|
# - allow_all_ext_traffic_to_local_service="$ext_if_static_1,9443,tcp"
|
||||||
|
# -
|
||||||
|
# - Do NOT add such a port to 'http_ports': that parameter is used in
|
||||||
|
# - many rules (FORWARD to local web servers, ..) and would open the
|
||||||
|
# - port far beyond what is needed.
|
||||||
# -
|
# -
|
||||||
# - Only 'tcp' and 'udp' are allowed values for protocol. A port range
|
# - Only 'tcp' and 'udp' are allowed values for protocol. A port range
|
||||||
# - can be given as 'from-to'.
|
# - can be given as 'from-to'.
|
||||||
@@ -466,6 +486,13 @@ allow_to_ext_net=""
|
|||||||
# - Note: Fields are separated by comma (not colon) because of IPv6 addresses.
|
# - Note: Fields are separated by comma (not colon) because of IPv6 addresses.
|
||||||
# -
|
# -
|
||||||
# - Example:
|
# - Example:
|
||||||
|
# - nginx on the gateway listens on port 9443 and forwards requests to
|
||||||
|
# - http://[fd2c:d4d1:4f03:10::13]:9663:
|
||||||
|
# -
|
||||||
|
# - allow_all_ext_traffic_to_local_service="$ext_if_static_1,9443,tcp"
|
||||||
|
# - allow_gw_to_local_service="fd2c:d4d1:4f03:10::13,9663,tcp"
|
||||||
|
# -
|
||||||
|
# - Further example with a port range:
|
||||||
# - allow_gw_to_local_service="fd2c:d4d1:4f03:10::13,9663,tcp
|
# - allow_gw_to_local_service="fd2c:d4d1:4f03:10::13,9663,tcp
|
||||||
# - fd2c:d4d1:4f03:10::20,8000-8010,tcp"
|
# - fd2c:d4d1:4f03:10::20,8000-8010,tcp"
|
||||||
# -
|
# -
|
||||||
|
|||||||
@@ -1469,9 +1469,17 @@ if [[ ${#allow_all_ext_traffic_to_local_service_arr[@]} -gt 0 ]] \
|
|||||||
|
|
||||||
IFS=',' read -a _val_arr <<< "${_val}"
|
IFS=',' read -a _val_arr <<< "${_val}"
|
||||||
|
|
||||||
|
# - An extern interface is given instead of an address (e.g. $ext_if_static_1):
|
||||||
|
# - allow traffic to the gateway itself coming in on that interface.
|
||||||
|
# -
|
||||||
|
if containsElement "${_val_arr[0]}" "${ext_if_arr[@]}" ; then
|
||||||
|
$ip6t -A INPUT -i ${_val_arr[0]} -p ${_val_arr[2]} --dport ${_val_arr[1]} -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
for _dev in ${ext_if_arr[@]} ; do
|
for _dev in ${ext_if_arr[@]} ; do
|
||||||
|
|
||||||
if containsElement "${_val_arr[0]}" "${gateway_ipv4_address_arr[@]}" ; then
|
if containsElement "${_val_arr[0]}" "${gateway_ipv6_address_arr[@]}" ; then
|
||||||
$ip6t -A INPUT -i $_dev -p ${_val_arr[2]} -d ${_val_arr[0]} --dport ${_val_arr[1]} -m conntrack --ctstate NEW -j ACCEPT
|
$ip6t -A INPUT -i $_dev -p ${_val_arr[2]} -d ${_val_arr[0]} --dport ${_val_arr[1]} -m conntrack --ctstate NEW -j ACCEPT
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -2150,6 +2150,14 @@ if [[ ${#allow_all_ext_traffic_to_local_service_arr[@]} -gt 0 ]] \
|
|||||||
|
|
||||||
IFS=':' read -a _val_arr <<< "${_val}"
|
IFS=':' read -a _val_arr <<< "${_val}"
|
||||||
|
|
||||||
|
# - An extern interface is given instead of an address (e.g. $ext_if_static_1):
|
||||||
|
# - allow traffic to the gateway itself coming in on that interface.
|
||||||
|
# -
|
||||||
|
if containsElement "${_val_arr[0]}" "${ext_if_arr[@]}" ; then
|
||||||
|
$ipt -A INPUT -i ${_val_arr[0]} -p ${_val_arr[2]} --dport ${_val_arr[1]} -m conntrack --ctstate NEW -j ACCEPT
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
for _dev in ${ext_if_arr[@]} ; do
|
for _dev in ${ext_if_arr[@]} ; do
|
||||||
|
|
||||||
if containsElement "${_val_arr[0]}" "${gateway_ipv4_address_arr[@]}" ; then
|
if containsElement "${_val_arr[0]}" "${gateway_ipv4_address_arr[@]}" ; then
|
||||||
|
|||||||
Reference in new issue
Block a user