Gate: Support AIO deployments when multiple default routes present

This PS updates the gateway setup script to support deployments where
multiple default routes may be present, eg when connecting to a vpn.

Change-Id: I5fe86e9471ecb6a9c80e1e4f942822cac00da669
Signed-off-by: Pete Birley <pete@port.direct>
This commit is contained in:
Pete Birley 2020-01-08 14:19:59 -06:00 committed by Pete Birley
parent 033ea6449b
commit c31f561641

View File

@ -28,8 +28,10 @@ sudo ip link set br-ex up
# VMs to reach the outside world correctly this needs to be set to ACCEPT.
sudo iptables -P FORWARD ACCEPT
# Setup masquerading on default route dev to public subnet
DEFAULT_ROUTE_DEV="$(sudo ip -4 route list 0/0 | awk '{ print $5; exit }')"
# Setup masquerading on default route dev to public subnet by searching for the
# interface with default routing, if multiple default routes exist then select
# the one with the lowest metric.
DEFAULT_ROUTE_DEV=$(route -n | awk '/^0.0.0.0/ { print $5 " " $NF }' | sort | awk '{ print $NF; exit }')
sudo iptables -t nat -A POSTROUTING -o ${DEFAULT_ROUTE_DEV} -s ${OSH_EXT_SUBNET} -j MASQUERADE
# NOTE(portdirect): Setup DNS for public endpoints