github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/e2e/forwarder/docker-entrypoint.sh (about)

     1  #!/bin/bash
     2  set -e
     3  
     4  setDefaultRoute() {
     5      GW=$1;
     6      ip route del default
     7      ip route add default via ${GW}
     8  }
     9  
    10  if [ -n "$EXT_NAT" ]; then
    11      echo "external NAT for containers via: ${EXT_NAT}"
    12      iptables -t nat -A POSTROUTING -o `ip r get ${EXT_NAT} | awk '{ print $3 }'` ! -d 172.16.0.0/12 -j MASQUERADE
    13  fi
    14  
    15  if [ -n "$GATEWAY" ]; then
    16      echo "new gateway: ${GATEWAY}"
    17      iptables -t nat -A POSTROUTING -o `ip r get ${GATEWAY} | awk '{ print $3 }'` -j MASQUERADE
    18      setDefaultRoute ${GATEWAY}
    19  fi
    20  
    21  if [ -n "$DEFAULT_ROUTE" ]; then
    22      echo "new default route: ${DEFAULT_ROUTE}"
    23      setDefaultRoute ${DEFAULT_ROUTE}
    24  fi
    25  
    26  dnsmasq --keep-in-foreground --bind-dynamic