web-dev-qa-db-fra.com

openVPN se connecte mais ne fonctionne pas la plupart du temps (RTNETLINK répond: Le fichier existe)

J'ai récemment créé un serveur openVPN, et je peux parfois me connecter (en utilisant openVPN sur elementryOS) et accéder parfaitement à Internet, mais la plupart du temps, je me connecte mais j'obtiens des erreurs DNS lorsque j'essaie d'accéder à un site Web.

Mon ami est capable de se connecter parfaitement à partir d’un mac en utilisant tunnelblick.

Quand je le démarre et que ça ne marche pas, j'obtiens cette sortie:

root@cclient:~# openvpn --config /home/user/vpn/client.ovpn 
Thu Aug 11 09:40:30 2016 OpenVPN 2.3.2 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [eurephia] [MH] [IPv6] built on Dec  1 2014
Thu Aug 11 09:40:30 2016 Control Channel Authentication: tls-auth using INLINE static key file
Thu Aug 11 09:40:30 2016 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Aug 11 09:40:30 2016 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Aug 11 09:40:30 2016 Socket Buffers: R=[212992->131072] S=[212992->131072]
Thu Aug 11 09:40:30 2016 NOTE: UID/GID downgrade will be delayed because of --client, --pull, or --up-delay
Thu Aug 11 09:40:30 2016 UDPv4 link local: [undef]
Thu Aug 11 09:40:30 2016 UDPv4 link remote: [AF_INET]99.139.69.XX:1194
Thu Aug 11 09:40:30 2016 TLS: Initial packet from [AF_INET]99.139.69.94:1194, sid=dcc35439 e95aefe1
Thu Aug 11 09:40:30 2016 VERIFY OK: depth=1, C=US, ST=CA, L=SanFrancisco, O=Marvin, OU=MyOrganizationalUnit, CN=Marvin CA, name=server, [email protected]
Thu Aug 11 09:40:30 2016 Validating certificate key usage
Thu Aug 11 09:40:30 2016 ++ Certificate has key usage  00a0, expects 00a0
Thu Aug 11 09:40:30 2016 VERIFY KU OK
Thu Aug 11 09:40:30 2016 Validating certificate extended key usage
Thu Aug 11 09:40:30 2016 ++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
Thu Aug 11 09:40:30 2016 VERIFY EKU OK
Thu Aug 11 09:40:30 2016 VERIFY OK: depth=0, C=US, ST=CA, L=SanFrancisco, O=Marvin, OU=MyOrganizationalUnit, CN=server, name=server, [email protected]
Thu Aug 11 09:40:30 2016 Data Channel Encrypt: Cipher 'BF-CBC' initialized with 128 bit key
Thu Aug 11 09:40:30 2016 Data Channel Encrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Aug 11 09:40:30 2016 Data Channel Decrypt: Cipher 'BF-CBC' initialized with 128 bit key
Thu Aug 11 09:40:30 2016 Data Channel Decrypt: Using 160 bit message hash 'SHA1' for HMAC authentication
Thu Aug 11 09:40:30 2016 Control Channel: TLSv1, cipher TLSv1/SSLv3 DHE-RSA-AES256-SHA, 2048 bit RSA
Thu Aug 11 09:40:30 2016 [server] Peer Connection Initiated with [AF_INET]99.139.69.94:1194
Thu Aug 11 09:40:32 2016 SENT CONTROL [server]: 'Push_REQUEST' (status=1)
Thu Aug 11 09:40:32 2016 Push: Received control message: 'Push_REPLY,redirect-gateway def1 bypass-dhcp,dhcp-option DNS 208.67.222.222,dhcp-option DNS 208.67.220.220,route 10.8.0.1,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.10 10.8.0.9'
Thu Aug 11 09:40:32 2016 OPTIONS IMPORT: timers and/or timeouts modified
Thu Aug 11 09:40:32 2016 OPTIONS IMPORT: --ifconfig/up options modified
Thu Aug 11 09:40:32 2016 OPTIONS IMPORT: route options modified
Thu Aug 11 09:40:32 2016 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified
Thu Aug 11 09:40:32 2016 ROUTE_GATEWAY 10.245.243.254/255.255.252.0 IFACE=wlan0 HWADDR=b4:6d:83:25:c7:95
Thu Aug 11 09:40:32 2016 TUN/TAP device tun0 opened
Thu Aug 11 09:40:32 2016 TUN/TAP TX queue length set to 100
Thu Aug 11 09:40:32 2016 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Thu Aug 11 09:40:32 2016 /sbin/ip link set dev tun0 up mtu 1500
Thu Aug 11 09:40:32 2016 /sbin/ip addr add dev tun0 local 10.8.0.10 peer 10.8.0.9
Thu Aug 11 09:40:32 2016 /sbin/ip route add 99.139.69.XX/32 via 10.245.XXX.254
RTNETLINK answers: File exists
Thu Aug 11 09:40:32 2016 ERROR: Linux route add command failed: external program exited with error status: 2
Thu Aug 11 09:40:32 2016 /sbin/ip route add 0.0.0.0/1 via 10.8.0.9
Thu Aug 11 09:40:32 2016 /sbin/ip route add 128.0.0.0/1 via 10.8.0.9
Thu Aug 11 09:40:32 2016 /sbin/ip route add 10.8.0.1/32 via 10.8.0.9
Thu Aug 11 09:40:32 2016 GID set to nogroup
Thu Aug 11 09:40:32 2016 UID set to nobody
Thu Aug 11 09:40:32 2016 Initialization Sequence Completed

Puis quand je presse ^ C je reçois

Thu Aug 11 09:44:57 2016 event_wait : Interrupted system call (code=4)
Thu Aug 11 09:44:57 2016 /sbin/ip route del 10.8.0.1/32
 RTNETLINK answers: Operation not permitted
 Thu Aug 11 09:44:57 2016 ERROR: Linux route delete command failed: external program exited with error status: 2
 Thu Aug 11 09:44:57 2016 /sbin/ip route del 99.139.69.94/32
 RTNETLINK answers: Operation not permitted
 Thu Aug 11 09:44:57 2016 ERROR: Linux route delete command failed: external program exited with error status: 2
 Thu Aug 11 09:44:57 2016 /sbin/ip route del 0.0.0.0/1
 RTNETLINK answers: Operation not permitted
 Thu Aug 11 09:44:57 2016 ERROR: Linux route delete command failed: external program exited with error status: 2
 Thu Aug 11 09:44:57 2016 /sbin/ip route del 128.0.0.0/1
 RTNETLINK answers: Operation not permitted
 Thu Aug 11 09:44:57 2016 ERROR: Linux route delete command failed: external program exited with error status: 2
 Thu Aug 11 09:44:57 2016 Closing TUN/TAP interface
 Thu Aug 11 09:44:57 2016 /sbin/ip addr del dev tun0 local 10.8.0.10 peer 10.8.0.9
 RTNETLINK answers: Operation not permitted
 Thu Aug 11 09:44:57 2016 Linux ip addr del failed: external program exited with error status: 2
 Thu Aug 11 09:44:57 2016 SIGINT[hard,] received, process exiting

Ceci est mon client.ovpn

##############################################
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server.     #
#                                            #
# This configuration can be used by multiple #
# clients, however each client should have   #
# its own cert and key files.                #
#                                            #
# On Windows, you might want to rename this  #
# file so it has a .ovpn extension           #
##############################################

# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client

# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one.  On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
;dev-node MyTap

# Are we connecting to a TCP or
# UDP server?  Use the same setting as
# on the server.
;proto tcp
proto udp

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote 99.139.69.XX 1194
;remote my-server-2 1194

# Choose a random Host from the remote
# list for load-balancing.  Otherwise
# try hosts in the order specified.
;remote-random

# Keep trying indefinitely to resolve the
# Host name of the OpenVPN server.  Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite

# Most clients don't need to bind to
# a specific local port number.
nobind

# Downgrade privileges after initialization (non-Windows only)
user nobody
group nogroup


# Try to preserve some state across restarts.
persist-key
persist-tun

# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here.  See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]

# Wireless networks often produce a lot
# of duplicate packets.  Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings

# SSL/TLS parms.
# See the server config file for more
# description.  It's best to use
# a separate .crt/.key file pair
# for each client.  A single ca
# file can be used for all clients.
#ca ca.crt
#cert client.crt
#key client.key
key-direction 1


# Verify server certificate by checking that the
# certicate has the correct key usage set.
# This is an important precaution to protect against
# a potential attack discussed here:
#  http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the keyUsage set to
#   digitalSignature, keyEncipherment
# and the extendedKeyUsage to
#   serverAuth
# EasyRSA can do this for you.
remote-cert-tls server

# If a tls-auth key is used on the server
# then every client must also have the key.
;tls-auth ta.key 1

# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
;cipher x

# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
comp-lzo

# Set log file verbosity.
verb 3

# Silence repeating messages
;mute 20
<ca>
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
</ca>
<cert>
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 4 (0x4)
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: C=US, ST=CA, L=SanFrancisco, O=Marvin, OU=MyOrganizationalUnit, CN=Marvin CA/name=server/[email protected]
        Validity
            Not Before: Aug  7 20:11:38 2016 GMT
            Not After : Aug  5 20:11:38 2026 GMT
        Subject: C=US, ST=CA, L=SanFrancisco, O=Marvin, OU=MyOrganizationalUnit, CN=theo/name=server/[email protected]
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:

                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Comment: 
                Easy-RSA Generated Certificate
            X509v3 Subject Key Identifier:
            X509v3 Authority Key Identifier: 
                keyid:
                DirName:/C=US/ST=CA/L=SanFrancisco/O=Marvin/OU=MyOrganizationalUnit/CN=Marvin CA/name=server/[email protected]
                serial:

            X509v3 Extended Key Usage: 
                TLS Web Client Authentication
            X509v3 Key Usage: 
                Digital Signature
            X509v3 Subject Alternative Name: 
                DNS:client
    Signature Algorithm: sha256WithRSAEncryption
             <STUFF HERE>
-----BEGIN CERTIFICATE-----

-----END CERTIFICATE-----
</cert>
<key>
-----BEGIN PRIVATE KEY-----

-----END PRIVATE KEY-----
</key>
<tls-auth>
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----

-----END OpenVPN Static key V1-----
</tls-auth>
3
Chtapodi

Donc, j'ai remarqué que vous ne poussez pas de paramètres DHCP ou autres. Pouvez-vous essayer d’ajouter ces lignes à votre client OVPN: Appuyez sur "dhcp-option DNS 8.8.8.8" "Push" dhcp-option DNS 8.8.4.4 "

Cela l'obligera à utiliser ces serveurs DNS (ces adresses sont des serveurs DNS de Google. Si vous avez déjà un serveur DNS sur votre réseau, veuillez utiliser cette adresse IP.) Il ya peut-être, il peut fournir des informations supplémentaires sur la configuration du réseau OVPN.

buntu en tant que serveur domestique | Blog de Denis Gladkikh

1
Ozymandias

cela semble être un problème de privilèges. Vous pouvez rétrograder des privilèges dans votre client.ovpn comme solution de contournement.

Ouvrez votre /home/user/vpn/client.ovpn dans un éditeur (nano/vim/emacs/gedit, etc.) et décommentez les lignes user et group.

Changer les lignes de ceci:

# Downgrade privileges after initialization (non-Windows only)
;user nobody
;group nogroup

Pour ça:

# Downgrade privileges after initialization (non-Windows only)
user nobody
group nogroup
0
C M Burns