Skip to content

Instantly share code, notes, and snippets.

@honwen
Last active June 4, 2021 19:24
Show Gist options
  • Save honwen/6c93c2ca8ed45ea20e53fdf22e18e752 to your computer and use it in GitHub Desktop.
Save honwen/6c93c2ca8ed45ea20e53fdf22e18e752 to your computer and use it in GitHub Desktop.
systemd-networkd_google2vpn.sh
#!/bin/bash
gw=${1:-123.234.123.234}
curl -skSL https://www.gstatic.com/ipranges/goog.json |
jq -r '.prefixes[] | .ipv4Prefix | select(length > 0)' |
while read cidr; do
cat <<EOF
[Route]
Destination=$cidr
Gateway=$gw
GatewayOnlink=yes
EOF
done
curl -skSL https://ip-ranges.amazonaws.com/ip-ranges.json |
jq -r '.prefixes[] | .ipv4Prefix | select(length > 0)' |
while read cidr; do
cat <<EOF
[Route]
Destination=$cidr
Gateway=$gw
GatewayOnlink=yes
EOF
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment