On 08/24/2015 06:35 AM, theman wrote:
> Okay, when I test manually from the terminal things appear more stable
> and I don't think I'm getting and dns leaks. VPN is up notification
> appears.
>
> $ sudo openvpn --writepid /var/run/openvpn/openvpn-client.pid --cd
> /rw/config/openvpn/ --config user.ovpn
>
> Note, I changed the command slightly at the end from " --config
> openvpn-client.ovpn" to, " --config user.ovpn" because that is the name
> of my *.ovpn file (in the /rw/config/openvpn folder). Is that correct?
Yes, that's right.
> And I'm still using Olivier's "vpn-setup.sh" file. I'm reluctant to user
> the resolv.conf as I think my nameservers change as my servers are
> random? My "user.ovpn" file supplied by my vpn provider lists several
> remote servers and has the entries;
> remote-random
> ns-cert-type server
My provider's (gateway) servers are also random. But nameservers always
stay static in my experience, and some providers might not add
nameserver info to their DHCP handshake.
Continuing to use Olivier's script without an openvpn user may be a
problem as those routing commands that aren't completing may be
necessary to ensure link security or efficiency. But using it /with/ the
openvpn user may also present problems... I think Olivier would need to
chime in here and describe the preconditions for its proper operation.
One important precondition is adding a "user openvpn" line to your .ovpn
file.
> (and also has "script-security 2")
>
> I changed "keepalive 3 10" to "keepalive 20 120"
That's probably for the better. The "3 10" timing looks rather aggressive.
> Everything appears to be running stable the past hour or so, no dns
> leaks, no drop-outs.
>
> Inactivity timeouts have gone, but I'm still getting the other two
> errors, including:
> chown: invalid user: 'openvpn'
>
> I have found this link but it's beyond my comprehension:
>
>
https://community.openvpn.net/openvpn/wiki/UnprivilegedUser
The 'User' section has six commands that should get the openvpn user
configured properly *after* you create it with "sudo useradd -M openvpn"
though in the VM you'll have to precede each command with "sudo":
> [root@hostname ~]# mkdir /var/lib/openvpn
> [root@hostname ~]# chown openvpn:openvpn /var/lib/openvpn
> [root@hostname ~]# usermod -d /var/lib/openvpn -s /sbin/nologin openvpn
> [root@hostname ~]# mkdir /var/log/openvpn
> [root@hostname ~]# chown openvpn:openvpn /var/run/openvpn /var/log/openvpn /etc/openvpn -R
> [root@hostname ~]# chmod u+w /var/run/openvpn /var/log/openvpn -R
Since we use a different working dir for openvpn, one more command:
sudo chown openvpn:openvpn /rw/config/openvpn
> Automatic test:
> Trying to use the downloaded "openvpn-client.service" and "rc.local" -
> result: the vpn gets up, without notification and dns is wrong (my
> ISPs). Before testing I reverted back to the original name of the
> "openvpn-client.service" file, however, I did change the latter part of
> the script inside the file to align with the command I used in per my
> manual test (from " --config openvpn-client.ovpn" to, " --config
> user.ovpn"). Is that correct?
Yes, that's right.
The lack of notification may stem from running the script as
(unprivileged) openvpn user. Try changing the 2 instances of this:
su -c 'notify-send -i /usr/share/pixmaps/faces/tennis-ball.png "VPN IS
UP"' user
...to this:
notify-send -i /usr/share/pixmaps/faces/tennis-ball.png "VPN IS UP"
> Question: I entered and ticked "openvpn-client" as a service in the VM
> manager GUI under the service tabs? Is that correct?
No, I didn't do it this way because the VM doesn't know what the
openvpn-client.service is until the rc.local script runs. Its done this
way so that you don't have to configure your template (and thus all
other VMs that use it) with a new service -- so the template is
untouched by the VPN setup which runs only in the VPN VM.