1

I got an openVPN config file from my vpn provider. It worked great on Ubuntu, but on alpine, I got an error.

The following lines fail:

up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

/etc/openvpn/update-resolv-conf does not exists on alpine Linux but /etc/openvpn/up.sh and /etc/openvpn/down.sh do.

the log contains the following output:

Options error: --up script fails with '/etc/openvpn/update-resolv-conf': No such file or directory (errno=2)
Options error: Please correct this error.
Use --help for more information.
  • Hi @Peter. Would you please add the error messages that you got! what do you mean by The following lines fail:? Failed where? and how you identified that these lines had failed? More clarifications will help us understand your problem much better, as a result give you an accurate answer ;-) – user88036 Sep 22 '18 at 9:25
  • 1
    @Goro i added the logfile content. – Peter Sep 22 '18 at 14:06
  • @Goro the command returns grep: /etc/resolvconf/resolv.conf.d/*: No such file or directory but i do have /etc/resolv.conf – Peter Sep 22 '18 at 14:18
  • Would you please cd /etc/resolvconf/ then list the files i.e. run ls are there files in that path? – user88036 Sep 22 '18 at 17:45
  • That directory does not exist. – Peter Sep 22 '18 at 20:09
2

It seems like the OpenVPN for Alpine Linux package does not include all the necessary scripts. If you know the address of the DNS servers your VPN provider uses, then you can use this simple workaround. You can also use a public DNS server such as Cloudflare DNS (1.1.1.1):

  1. Enter the command: sudo nano /etc/openvpn/update-resolv-conf. The Nano text editor should open.
  2. The file should be empty. Paste the following into the file:

    #!/bin/bash
    if [ -e /etc/resolv.conf.old ]; then
        mv /etc/resolv.conf.old /etc/resolv.conf
        chmod 777 /etc/resolv.conf
        exit
    fi
    mv /etc/resolv.conf /etc/resolv.conf.old
    cp /etc/resolv.conf.new /etc/resolv.conf
    chmod 777 /etc/resolv.conf
    
  3. Press Ctrl+X, then Y, then press Enter to save the file.

  4. Enter the command: sudo nano /etc/resolv.conf.new, then type nameserver [address of VPN's DNS server].
  5. Press Ctrl+X, then Y, then press Enter to save the file.

That should make a new copy of resolv.conf (resolv.conf.new), and copy it to resolv.conf when the VPN activates, then copy back the old resolv.conf when the VPN ends.

  • (1) When does your /etc/openvpn/update-resolv-conf script run?  What runs it?  (2) Do you really believe that it’s a good idea to leave the /etc/resolv.conf file world-writable?  (3) When you say “type nameserver …”, do you mean type nameserver, or do you mean type the IP address of your name server? (You should use code formatting only for literal text, and not descriptions or placeholders.) – G-Man Sep 26 '18 at 1:30
  • I'll just say, this similar to what I use on my setup so it may not be exactly what you want. The update-resolv-conf script runs whenever the .ovpn config file calls it (the lines 'up /etc/openvpn/update-resolv-conf' and 'down /etc/openvpn/update-resolv-conf'). In this case, it runs when the tunnel is established and terminated. I have changed my answer to make resolv.conf 755. When I say "type 'nameserver'", I mean type the word 'nameserver' and then '[SPACE]' and then type the DNS server's address. – wispi Sep 26 '18 at 3:20

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.