Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

Commit

Permalink
Close #23
Browse files Browse the repository at this point in the history
disable OutboundIPRanges configuration when OutboundPorts set
  • Loading branch information
kevin21th committed Sep 5, 2018
1 parent d636440 commit f71c826
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
Expand Up @@ -31,11 +31,11 @@ data:
{{ "[[ if (isset .ObjectMeta.Annotations \"traffic.sidecar.istio.io/includeOutboundPorts\") -]]" }}
- "-o"
{{ "- \"[[ index .ObjectMeta.Annotations \"traffic.sidecar.istio.io/includeOutboundPorts\" ]]\"" }}
{{ "[[ end -]]" }}
{{ "[[ if (isset .ObjectMeta.Annotations \"traffic.sidecar.istio.io/excludeOutboundPorts\") -]]" }}
- "-z"
{{ "- \"[[ index .ObjectMeta.Annotations \"traffic.sidecar.istio.io/excludeOutboundPorts\" ]]\"" }}
{{ "[[ end -]]" }}
{{ "[[ end -]]" }}
{{ "[[ else -]]" }}
- "-i"
{{ "[[ if (isset .ObjectMeta.Annotations \"traffic.sidecar.istio.io/includeOutboundIPRanges\") -]]" }}
{{ "- \"[[ index .ObjectMeta.Annotations \"traffic.sidecar.istio.io/includeOutboundIPRanges\" ]]\"" }}
Expand All @@ -48,6 +48,7 @@ data:
{{ "[[ else -]]" }}
- "{{ .Values.global.proxy.excludeIPRanges }}"
{{ "[[ end -]]" }}
{{ "[[ end -]]" }}
- "-b"
{{ "[[ if (isset .ObjectMeta.Annotations \"traffic.sidecar.istio.io/includeInboundPorts\") -]]" }}
{{ "- \"[[ index .ObjectMeta.Annotations \"traffic.sidecar.istio.io/includeInboundPorts\" ]]\"" }}
Expand Down
30 changes: 14 additions & 16 deletions tools/deb/istio-iptables.sh
Expand Up @@ -287,24 +287,22 @@ done
iptables -t nat -A ISTIO_OUTPUT -d 127.0.0.1/32 -j RETURN

if [ -n "${OUTBOUND_PORTS_INCLUDE}" ]; then
if [ -n "${OUTBOUND_PORTS_INCLUDE}" ]; then
if [ "${OUTBOUND_PORTS_INCLUDE}" == "*" ]; then
# Redirect exclusions must be applied before inclusions.
if [ -n "${OUTBOUND_PORTS_EXCLUDE}" ]; then
for port in ${OUTBOUND_PORTS_EXCLUDE}; do
iptables -t nat -A ISTIO_OUTPUT -p tcp --dport ${port} -j RETURN
done
fi
# Redirect remaining outbound traffic to Envoy
iptables -t nat -A ISTIO_OUTPUT -j ISTIO_REDIRECT
else
# User has specified a non-empty list of ports to be redirected to Envoy.
for port in ${OUTBOUND_PORTS_INCLUDE}; do
iptables -t nat -A ISTIO_OUTPUT -p tcp --dport ${port} -j ISTIO_REDIRECT
if [ "${OUTBOUND_PORTS_INCLUDE}" == "*" ]; then
# Redirect exclusions must be applied before inclusions.
if [ -n "${OUTBOUND_PORTS_EXCLUDE}" ]; then
for port in ${OUTBOUND_PORTS_EXCLUDE}; do
iptables -t nat -A ISTIO_OUTPUT -p tcp --dport ${port} -j RETURN
done
# All other traffic is not redirected.
iptables -t nat -A ISTIO_OUTPUT -j RETURN
fi
# Redirect remaining outbound traffic to Envoy
iptables -t nat -A ISTIO_OUTPUT -j ISTIO_REDIRECT
else
# User has specified a non-empty list of ports to be redirected to Envoy.
for port in ${OUTBOUND_PORTS_INCLUDE}; do
iptables -t nat -A ISTIO_OUTPUT -p tcp --dport ${port} -j ISTIO_REDIRECT
done
# All other traffic is not redirected.
iptables -t nat -A ISTIO_OUTPUT -j RETURN
fi
else
if [ "${OUTBOUND_IP_RANGES_INCLUDE}" == "*" ]; then
Expand Down

0 comments on commit f71c826

Please sign in to comment.