0

I am trying to get a Void Linux system working with OpenVPN, and this is my first attempt at creating my own runit service. The OpenVPN package on Void Linux does not supply any init files or any configuration files in /etc/openvpn

I created the user openvpn and created /etc/openvpn/client and I put the following configuration file in it:

client
dev tun
proto udp

verb 5

#Server IP and Port
remote [redacted] 1194

user openvpn
group openvpn

resolv-retry infinite
nobind
persist-key
persist-tun
mute-replay-warnings
ca /etc/openvpn/client/ca.crt
cert /etc/openvpn/client/client.crt
key /etc/openvpn/client/client.key
tls-auth /etc/openvpn/client/ta.key 1
remote-cert-tls server

I then went to create my own runit service for OpenVPN by making the directory /etc/sv/openvpn and I created the run file in /etc/sv/openvpn/run with the following contents:

#!/bin/sh

[ -r conf ] && . ./conf
exec /usr/bin/openvpn --config /etc/openvpn/client/client.conf --daemon $OPTS

I made that service file executable and then went to start the OpenVPN process with the following command:

# sv start openvpn
ok: run: openvpn: (pid 858) 0s

It appears to have worked and so I check if the tun0 interface is running, and it is:

4: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 500
    link/none
    inet 10.8.0.102 peer 10.8.0.101/32 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::475f:cd8d:32e1:2af3/64 scope link stable-privacy
       valid_lft forever preferred_lft forever

However after a few more seconds another tunnel interface is created, and so on again and again:

5: tun1: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 500
    link/none 
    inet 10.8.0.102 peer 10.8.0.101/32 scope global tun1
       valid_lft forever preferred_lft forever
    inet6 fe80::fa30:8bfb:2168:6d7b/64 scope link stable-privacy 
       valid_lft forever preferred_lft forever
6: tun2: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 500
    link/none 
    inet 10.8.0.102 peer 10.8.0.101/32 scope global tun2
       valid_lft forever preferred_lft forever
    inet6 fe80::8366:3479:ee34:5f47/64 scope link stable-privacy 
       valid_lft forever preferred_lft forever

For some reason my runit service keeps spawning OpenVPN over and over. Here are the processes:

openvpn    865  0.1  0.5   9636  5864 ?        Ss   19:22   0:00 /usr/bin/openvpn --config /etc/openvpn/client/client.conf --daemon
root       869  0.2  0.5   9636  5784 ?        Ss   19:22   0:00 /usr/bin/openvpn --config /etc/openvpn/client/client.conf --daemon
root       871  0.0  0.5   9636  5784 ?        Ss   19:22   0:00 /usr/bin/openvpn --config /etc/openvpn/client/client.conf --daemon
root       877  0.3  0.5   9636  5892 ?        Ss   19:22   0:00 /usr/bin/openvpn --config /etc/openvpn/client/client.conf --daemon
openvpn    879  0.3  0.5   9636  5912 ?        Ss   19:22   0:00 /usr/bin/openvpn --config /etc/openvpn/client/client.conf --daemon
1
  • It's client side, why don't you just use NetworkManager-openvpn? – Jiri B Mar 11 at 14:04
0

The problem is --daemon, daemons managed by runit should not go to background themselves. See how it is done for sshd, exec /usr/bin/sshd -D $OPTS, where -D means sshd will not detach and does not become daemon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.