|
|
|
@ -86,3 +86,35 @@ foreach($yaml in (Get-ChildItem -Filter '*.yml')) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#TODO: port from bash
|
|
|
|
|
|
|
|
|
|
chain_rule='-m addrtype --dst-type LOCAL -j SWARM-NAT'
|
|
|
|
|
if ! iptables -t nat -C PREROUTING $chain_rule; then
|
|
|
|
|
Write-Output 'Add jump rule for SWARM-NAT'
|
|
|
|
|
iptables -t nat -A PREROUTING $chain_rule
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bridge=$(
|
|
|
|
|
docker network inspect docker_gwbridge \
|
|
|
|
|
--format '{{(index .Containers "ingress-sbox").IPv4Address}}' \
|
|
|
|
|
| cut -d'/' -f1
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
internal_port=30000
|
|
|
|
|
public_port=30001
|
|
|
|
|
destination='145.239.119.128'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rule="-p tcp -m tcp --destination ""${destination}"" --dport ""${public_port}""
|
|
|
|
|
-j DNAT --to-destination ""${bridge}:${internal_port}"""
|
|
|
|
|
|
|
|
|
|
if ! iptables -t nat -C SWARM-NAT $rule > /dev/null; then
|
|
|
|
|
Write-Output "Add rule for NAT from ${destination}:${public_port} to ${bridge}:${internal_port}"
|
|
|
|
|
iptables -t nat -A SWARM-NAT $rule
|
|
|
|
|
else
|
|
|
|
|
Write-Output "Rule for NAT from ${destination}:${public_port} to ${bridge}:${internal_port} already exists"
|
|
|
|
|
fi
|