Skip to content

Openvpn with Configuration file

Martin Buchleitner edited this page Mar 2, 2021 · 1 revision

As I am using a VPN setup based on kylemenna-openvpn i used this project to transfer also the vpn connection setup to the udm-pro. So I created a custom startup script for this job:

#!/usr/bin/env sh

DEBUG=${DEBUG:--d}
CONTAINER_NAME="openvpn_nitram"

IS_RUNNING=$(podman ps --filter="name=$CONTAINER_NAME" --filter="status=running" -q)
if [ -n "$IS_RUNNING" ]; then
  echo "$CONTAINER_NAME[$IS_RUNNING] is already running..."
  exit 0
fi
IS_CREATED=$(podman ps --filter="name=$CONTAINER_NAME" --filter=status=created" -qa)
if [ -n "$IS_CREATED" ]; then
  echo "$CONTAINER_NAME[$IS_CREATED] is already created..."
  exit 0
fi

podman run --name custom_openvpn \
           --health-cmd=["pgrep","openvpn"] \
           --network=host \
           -v /dev/net/tun:/dev/net/tun \
           -v /mnt/data/ovpn:/tmp/vpn \
           --privileged \
           --restart=always \
           openvpn \
           ovpn_run /tmp/vpn/vpn_config.vpn

Because the original kylemenna-openvpn repository does not automatically build an aarch64 image you are forced to build this on your own by bringing the repository on the udm-pro ( e.g. by scp it ... ) and run following command within the git repository.

podman build -t openvpn .

This will generate the container used in the upper startup.sh script and you have to place the VPN configuration on /mnt/data/ovpn/ to just copy&paste these commands ;-)