| 1 | #!/bin/sh |
| 2 | # Brings up the tunnel to Snow Globe, the guest's only way off this Mac. |
| 3 | set -eu |
| 4 | D=/usr/local/libexec/ext-wg |
| 5 | gw=$(route -n get default | awk '/gateway:/ {print $2}') |
| 6 | rm -f /var/run/ext-wg.name |
| 7 | WG_TUN_NAME_FILE=/var/run/ext-wg.name "$D/wireguard-go" -f utun & |
| 8 | pid=$! |
| 9 | trap 'kill $pid' TERM INT |
| 10 | until [ -s /var/run/ext-wg.name ]; do sleep 0.2; done |
| 11 | if=$(cat /var/run/ext-wg.name) |
| 12 | "$D/wg" setconf "$if" /etc/ext-wg.conf |
| 13 | ifconfig "$if" inet 10.100.0.2 10.100.0.2 netmask 255.255.255.255 mtu 1200 up |
| 14 | route -q -n add -host 100.64.0.1 "$gw" |
| 15 | route -q -n add -inet 10.100.0.0/24 -interface "$if" |
| 16 | route -q -n add -inet 0.0.0.0/1 -interface "$if" |
| 17 | route -q -n add -inet 128.0.0.0/1 -interface "$if" |
| 18 | wait $pid |