Skip to content

Instantly share code, notes, and snippets.

@Fastidious
Last active July 19, 2019 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fastidious/d0162f7df2a2d3180b0e57e80df343ce to your computer and use it in GitHub Desktop.
Save Fastidious/d0162f7df2a2d3180b0e57e80df343ce to your computer and use it in GitHub Desktop.

The external interface is only required on the server, so you only need it once.

Here's a script the start the client. The gateway will be filled automatically:

dsvpn client \
  vpn.key \
  auto \
  192.168.192.1 192.168.192.254 \
  your.vpn.server.ip 443 \
  auto \
  $(netstat -rn | awk '/default/{if(index($6,"en")){print $2}}')

on Linux, replace the last line with ip route show default|awk '/default/{print $3}'.

As you can see, it's not any longer than a configuration file and offers more flexibility.

On the server, the external interface can be returned by ip route show default|awk '{print $3}'.

So a server script can just be:

dsvpn server \
  vpn.key \
  auto \
  192.168.192.254 192.168.192.1 \
  auto 443 \
  $(ip route show default|awk '{print $5}') \
  auto

Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment