QNAP Systems, Inc. - Network Attached Storage (NAS)

Language

Support

How to connect to OpenVPN server via .ovpn configuration file?

Applied Models:

Answer:

If you need to connect to an OpenVPN server using an .ovpn file, you can establish a connection through the following steps in QTS 4.2:

  1. Create a text file “openvpn_client_login.txt” with your username and password in it:
    Admin   Connection username
    Password123   Connection password
    Connect to the NAS via SSH (default port is 22) using the admin account and import these files to “/etc/openvpn”:
    1. The .ovpn configuration file (hereinafter referred to as “openvpn.ovpn”.)
    2. Certificate (hereinafter referred to as “ca.crt”, if it is not provided, then it is unnecessary.)
    3. Text file: “openvpn_client_login.txt”.
       
  2. Change mode openvpn_client_login.txt:
    chmod 600 /etc/openvpn/openvpn_client_login.txt
     
  3. Rename openvpn.ovpn:
    mv /etc/openvpn/openvpn.ovpn /etc/openvpn/client.conf
     
  4. Edit /etc/openvpn/client.conf:
    1. ca /etc/openvpn/ca.crt (Specify the certification location)
    2. auth-user-pass /etc/openvpn/openvpn_client_login.txt (Specify the username and password)
    3. up /etc/openvpn/openvpn_up
    4. down /etc/openvpn/openvpn_down
    Note: use the c. and d. entries if you want to set this VPN connection as the default gateway.
    Using the QNAP NAS' built-in OpenVPN Server configuration file as an example (modified parts are marked in yellow):
    client
    dev tun
    script-security 3
    proto tcp
    remote 172.17.20.134 1194
    resolv-retry infinite
    nobind
    ca /etc/openvpn/ca.crt
    auth-user-pass /etc/openvpn/openvpn_client_login.txt
    reneg-sec 0
    cipher AES-128-CBC
    writepid /var/run/openvpn.client.pid
    up /etc/openvpn/openvpn_up
    down /etc/openvpn/openvpn_down
    daemon openvpn-client
     
  5. Add the command lines in /etc/config/vpn.conf
    [OPENVPN_CLIENT4]
    Enable = TRUE
    Status = 1
    Index = 4
    Gateway = 1
    Allow Connect = 0
    Reconnect = 1
    Server Address = OpenVPN.myQNAPcloud.com
    Profile File = OpenVPN4
    VPN Proto Type = TCP
    VPN Port = 1194
    Compress = 1
    Re-direct gateway = 1
    Encryption = 1
    Name = admin
    AccessCode = AAA
    Time Stamp = 0
    Please follow these instructions and enter the bold red part:
    1. [OPENVPN_CLIENT4]: According to your established OpenVPN Client connection number +1. As in the following illustration: three OpenVPN connection is established, so enter: 4.
    2. Enable = TRUE: Enable this connection (it will be “False” when the connection is disconnected.)
    3. Status = 1: Enable this connection (it will be “0” when the connection is disconnected.)
    4. Index = 4: Same as item a.
    5. Gateway = 1: If you want to set this VPN connection to be the default gateway then set to 1, and vice versa, set to 0.
    6. Server Address = OpenVPN.myQNAPcloud.com: The VPN server’s IP address or domain.
    7. Profile File = OpenVPN4: The name shown on the VPN client page.
    8. VPN Proto Type = TCP: The VPN connection protocol.
    9. VPN Port = 1194: The VPN connection port number.
    10. Compress = 1: Enable compression, or set as 0 to disable it.
    11. Name = admin: The connection username.
       
  6. Start VPN connection:
    Enter the command: /etc/init.d/vpn_openvpn_client.sh start 4 &
    (Note: the number “4” is the index of this connection)
     
  7. Set DNS:
    Edit /etc/resolv.conf, adding the DNS IP address (e.g. 8.8.8.8)
    nameserver 8.8.8.8
    nameserver 10.8.2.11
    nameserver 172.16.2.11
     
  8. Check the connection:
    Enter ps | grep openvpn, If the reply contains the red part, it means that the connection has been established:
        6714 admin     536 R     grep openvpn
        31906 admin     2152 S     /usr/sbin/openvpnclient /etc/openvpn/client.conf
    Or you can go to VPN client page, the connection is already receiving and transmitting packets.
     
  9. Disconnect:
    Click “disconnect” in the VPN client page.
     
  10. Re-connect:
    Please note, if you want to reconnect to the VPN, do not click the “connect” button in the VPN client page. Please repeat these settings:
    1. Edit /etc/config/vpn.conf:
      Enable = TRUE
      Status = 1
    2. Enter the command line: # /etc/init.d/vpn_openvpn_client.sh start 4 &
Datum vydání: 2015-10-06
Bylo to pro vás to užitečné?
Děkujeme vám za vaši zpětnou vazbu.
Děkujeme vám za vaši zpětnou vazbu. Máte-li nějaké dotazy, kontaktujte prosím adresu support@qnap.com
26% lidí si myslí, že to pomáhá.