Skip to content

Instantly share code, notes, and snippets.

@giteshk
Created March 22, 2022 06:27
Show Gist options
  • Save giteshk/79e9e6c83712ebe5c4bb18da56456e14 to your computer and use it in GitHub Desktop.
Save giteshk/79e9e6c83712ebe5c4bb18da56456e14 to your computer and use it in GitHub Desktop.
sudo su -
$endpoint=$(curl -s http://metadata.google.internal/computeMetadata/v1/instance/attributes/FORWARD_IPADDRESS -H "Metadata-Flavor: Google")
if [ -x /bin/firewall-cmd ]
then
sysctl -w net.ipv4.ip_forward=1
firewall-cmd --permanent --add-masquerade
firewall-cmd --permanent --add-forward-port=port=443:proto=tcp:toaddr=$endpoint
else
sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination $endpoint
fi
sysctl -ew net.netfilter.nf_conntrack_buckets=1048576
sysctl -ew net.netfilter.nf_conntrack_max=8388608
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment