Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

missing -d flag from https://github.com/cloudfoundry-community/port-forwarding-boshrelease/blob/master/jobs/port_forwarding/templates/bin/forward_ports.sh.erb#L28 #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions jobs/port_forwarding/templates/bin/forward_ports.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ fi

iptables -F ${CHAIN} || true

# Reset in case when there is no localhost routing
sysctl net.ipv4.conf.all.route_localnet=0
sysctl net.ipv4.conf.all.route_localnet=1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would prefer if this stays as is, conditional.


<% p("networking.port_forwarding").each do |rule| %>
<% external_port = rule['external_port'] || raise("Expected non-empty 'external_port' on '#{rule.inspect}' rule") %>
<% internal_ip = rule['internal_ip'] || "127.0.0.1" %>
<% internal_port = rule['internal_port'] || raise("Expected non-empty 'internal_port' on '#{rule.inspect}' rule") %>
<%
external_ip = rule['external_ip'] || spec.address
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spec.address -> spec.ip. spec.address may be a dns name.

external_port = rule['external_port'] || raise("Expected non-empty 'external_port' on '#{rule.inspect}' rule")
internal_ip = rule['internal_ip'] || "127.0.0.1"
internal_port = rule['internal_port'] || raise("Expected non-empty 'internal_port' on '#{rule.inspect}' rule")
%>
# external clients
sudo iptables -t nat -A portforwarding-release -p tcp -d <%= external_ip %> --dport <%= external_port %> -j DNAT --to <%= internal_ip %>:<%= internal_port %>

# loopback
sudo iptables -t nat -A portforwarding-release -p tcp -d 127.0.0.1 --dport <%= external_port %> -j DNAT --to <%= internal_ip %>:<%= internal_port %> -o lo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should really be done thru port_forwarding config, instead of hard coded.


sudo iptables -t nat -A portforwarding-release -p tcp --dport <%= external_port %> -j DNAT --to <%= internal_ip %>:<%= internal_port %>

<% if internal_ip == "127.0.0.1" %>
sysctl net.ipv4.conf.all.route_localnet=1
<% end %>
<% end %>