Configuration OpenVpn / VPS

Venez poser ici vos questions de réseaux, partage de connexion, firewall, cablage et cie ....

Modérateur: Barbapapa

Configuration OpenVpn / VPS

Message par sevensam » 16 Déc 2016 23:10

Hello,

J'ai installer OpenVpn sur un VPS.

Je voulais donner accès a mon pc depuis l'extérieur, mais je n'y arrive pas.

J'ai pas de soucis a me connecter dessus(sur le serveur openvpn), tous les sites qui détecte mon ip me confirme l'ip/ptr de mon VPS, mais comment router l'adresse ip du VPS sur mon pc ? en gros je veux que l'ip du VPS pour mon pc local dans les deux sens (ici j'ai accès qu'en sortie surf anonyme par exemple, mais pour envoyer un fichier sur mon pc en sftp ftp ssh webserver, impossible)
J'avais réusis en PPTP, mais la j'ai du oublier une option

fichier serveur
port 1194
proto udp
dev tun
user nobody
group nogroup
persist-key
persist-tun
keepalive 10 120
topology subnet
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 80.67.169.12"
push "dhcp-option DNS 80.67.169.40"
push "redirect-gateway def1 bypass-dhcp"
crl-verify crl.pem
ca ca.crt
cert server.crt
key server.key
tls-auth tls-auth.key 0
dh dh.pem
auth SHA256
cipher AES-256-CBC
tls-server
tls-version-min 1.2
tls-cipher TLS-DHE-RSA-WITH-AES-128-GCM-SHA256
status openvpn.log
verb 3




fichier client (dans le fichier les clé son inséré)
client
proto udp
remote adresse ip 1194
dev tun
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
auth SHA256
cipher AES-256-CBC
tls-client
tls-version-min 1.2
tls-cipher TLS-DHE-RSA-WITH-AES-128-GCM-SHA256
setenv opt block-outside-dns
verb 3

des avis ?
Avatar de l’utilisateur
sevensam
Habitué
Habitué
 
Message(s) : 476
Inscription : 03 Jan 2005 19:22

Re: Configuration OpenVpn / VPS

Message par mackguil » 16 Déc 2016 23:18

Routing all client traffic (including web-traffic) through the VPN

Overview

By default, when an OpenVPN client is active, only network traffic to and from the OpenVPN server site will pass over the VPN. General web browsing, for example, will be accomplished with direct connections that bypass the VPN.

In certain cases this behavior might not be desirable -- you might want a VPN client to tunnel all network traffic through the VPN, including general internet web browsing. While this type of VPN configuration will exact a performance penalty on the client, it gives the VPN administrator more control over security policies when a client is simultaneously connected to both the public internet and the VPN at the same time.

Implementation

Add the following directive to the server configuration file:

push "redirect-gateway def1"
If your VPN setup is over a wireless network, where all clients and the server are on the same wireless subnet, add the local flag:

push "redirect-gateway local def1"
Pushing the redirect-gateway option to clients will cause all IP network traffic originating on client machines to pass through the OpenVPN server. The server will need to be configured to deal with this traffic somehow, such as by NATing it to the internet, or routing it through the server site's HTTP proxy.

On Linux, you could use a command such as this to NAT the VPN client traffic to the internet:

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
This command assumes that the VPN subnet is 10.8.0.0/24 (taken from the server directive in the OpenVPN server configuration) and that the local ethernet interface is eth0.

When redirect-gateway is used, OpenVPN clients will route DNS queries through the VPN, and the VPN server will need handle them. This can be accomplished by pushing a DNS server address to connecting clients which will replace their normal DNS server settings during the time that the VPN is active. For example:

push "dhcp-option DNS 10.8.0.1"
will configure Windows clients (or non-Windows clients with some extra server-side scripting) to use 10.8.0.1 as their DNS server. Any address which is reachable from clients may be used as the DNS server address.

Caveats

Redirecting all network traffic through the VPN is not entirely a problem-free proposition. Here are some typical gotchas to be aware of:

Many OpenVPN client machines connecting to the internet will periodically interact with a DHCP server to renew their IP address leases. The redirect-gateway option might prevent the client from reaching the local DHCP server (because DHCP messages would be routed over the VPN), causing it to lose its IP address lease.
Issues exist with respect to pushing DNS addresses to Windows clients.
Web browsing performance on the client will be noticably slower.
For more information on the mechanics of the redirect-gateway directive, see the manual page.


Source: https://openvpn.net/index.php/open-sour ... howto.html
Avatar de l’utilisateur
mackguil
Vingt mille
Vingt mille
 
Message(s) : 21326
Inscription : 14 Mai 2005 10:22
Localisation : Luik Belgium

Re: Configuration OpenVpn / VPS

Message par sevensam » 17 Déc 2016 12:58

oui j'ai déjà fait cela, mais rien a faire... J'ai du rater une étape quelque part, mais la je bloque...

J'ai fait le portforwarding ipv4 également, j'ai bien renseigner l'iptables... ca ne serais pas au niveau du vps peu être ?
Avatar de l’utilisateur
sevensam
Habitué
Habitué
 
Message(s) : 476
Inscription : 03 Jan 2005 19:22

Re: Configuration OpenVpn / VPS

Message par mackguil » 17 Déc 2016 13:12

sevensam a écrit :oui j'ai déjà fait cela, mais rien a faire... J'ai du rater une étape quelque part, mais la je bloque...

J'ai fait le portforwarding ipv4 également, j'ai bien renseigner l'iptables... ca ne serais pas au niveau du vps peu être ?


Iptable est installé sur le vps ?

Pourrais tu tester en quotant cette ligne s'il te plait.

Code : Tout sélectionner
push "redirect-gateway def1 bypass-dhcp"
Avatar de l’utilisateur
mackguil
Vingt mille
Vingt mille
 
Message(s) : 21326
Inscription : 14 Mai 2005 10:22
Localisation : Luik Belgium

Re: Configuration OpenVpn / VPS

Message par NuxPowa » 18 Avr 2017 19:45

Toujours aussi "speedy gonzalez" ici...
J'utilise aussi le server openvpn sous linux et le client sous windows.

Je vois bien l'icone réseau devenue verte avec "adrese ip signée 10.X.Y.Z" en dessous, mais lorsque je fais un "spedtest".net", il m'affiche toujours mon ip WAN belge...

Dans linux j'ai édité /etc/sysctl.conf et modifié net.ipv4.ip_forward = 1



Dans win7, en commande j'avais ajouté un mode admin
netsh advfirewall firewall add rule name="All ICMP V4" protocol=icmpv4:any,any dir=in action=allow

Maintenant, je ne sais si: c'est windows 7 qu bloque ou le serveur. Un ping fonctionne mais pourquoi toujours ma geolocalisation belge?
Roma non uno die aedificata est.
"Look after the pennies and the pounds will look after themselves"
vî trigu : sacwè ki n' sieve pu.
Avatar de l’utilisateur
NuxPowa
Acharné
Acharné
 
Message(s) : 4108
Inscription : 17 Jan 2004 16:12
Localisation : Condroz

Re: Configuration OpenVpn / VPS

Message par mackguil » 18 Avr 2017 21:17

NuxPowa a écrit :Toujours aussi "speedy gonzalez" ici...
J'utilise aussi le server openvpn sous linux et le client sous windows.

Je vois bien l'icone réseau devenue verte avec "adrese ip signée 10.X.Y.Z" en dessous, mais lorsque je fais un "spedtest".net", il m'affiche toujours mon ip WAN belge...

Dans linux j'ai édité /etc/sysctl.conf et modifié net.ipv4.ip_forward = 1



Dans win7, en commande j'avais ajouté un mode admin
netsh advfirewall firewall add rule name="All ICMP V4" protocol=icmpv4:any,any dir=in action=allow

Maintenant, je ne sais si: c'est windows 7 qu bloque ou le serveur. Un ping fonctionne mais pourquoi toujours ma geolocalisation belge?


Le push redirect gateway et le push option dns sont ils présents sur la config du serveur ?
Avatar de l’utilisateur
mackguil
Vingt mille
Vingt mille
 
Message(s) : 21326
Inscription : 14 Mai 2005 10:22
Localisation : Luik Belgium


Retour vers Discussion réseaux

Qui est en ligne ?

Utilisateur(s) parcourant ce forum : Aucun utilisateur inscrit