problem configure openvpn for one interface

Need help configuring your VPN? Just post here and you'll get that help.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Forum rules
Please use the [oconf] BB tag for openvpn Configurations. See viewtopic.php?f=30&t=21589 for an example.
Post Reply
azote26
OpenVpn Newbie
Posts: 2
Joined: Mon Aug 19, 2019 12:40 am

problem configure openvpn for one interface

Post by azote26 » Mon Aug 19, 2019 12:47 am

hello guys,

i'm trying to setup open vpn client to connect to tunnelbear vpn, and use it to do some anonymous requests in php with curl.

i'm doing that on a remote VPS, so if i do a mistake the vpn block me and i'm forced to reboot the vps.
actually my client config is like this :
config.ovpn

client
dev tun0
proto udp
nobind
ns-cert-type server
persist-key
persist-tun
reneg-sec 0
dhcp-option DNS 8.8.8.8
dhcp-option DNS 8.8.4.4
verb 3
auth-user-pass login.key
ca CACertificate.crt
cert UserCertificate.crt
key PrivateKey.key
remote fr.*.com 443
cipher AES-256-CBC
auth SHA256
keysize 256
keepalive 10 30
up vpnon.sh
down vpnoff.sh
script-security 2


i don't have any redirect gateway setup, because if i add it, my whole traffic go through the vpn and everything is blocked.
i just want to use the vpn for somes specials requests.

like :
whole traffic -> without vpn except for tun0 requests

i use this in php to use the vpn interface :
curl_setopt($ch, CURLOPT_INTERFACE, "tun0");

but the traffic seems to don't use the vpn cause the public ip of the curl request is not anonymous.

i'm very lost with all theses routes settings help me please :(

azote26
OpenVpn Newbie
Posts: 2
Joined: Mon Aug 19, 2019 12:40 am

Re: problem configure openvpn for one interface

Post by azote26 » Mon Aug 26, 2019 3:29 pm

problem solved by using this "up" script :

Code: Select all

 #!/bin/sh
    
    echo "$dev : $ifconfig_local -> $ifconfig_remote gw: $route_vpn_gateway"
    
    ip route add default via $route_vpn_gateway dev $dev table 20
    ip rule add from $ifconfig_local table 20
    ip rule add to $route_vpn_gateway table 20
    ip route flush cache
    
    exit 0
and this client conf :


Code: Select all

  client
    dev tun0
    proto udp
    remote fr.*.com 443
    resolv-retry infinite
    nobind
    persist-key
    persist-tun
    ca CACertificate.crt
    cert UserCertificate.crt
    key PrivateKey.key
    verb 5
    route-method exe
    route-delay 2
    tun-mtu 1500
    tun-mtu-extra 32
    mssfix 1450
    cipher AES-256-CBC
    auth SHA256
    keysize 256
    comp-lzo
    auth-user-pass login.key
    script-security 2
    route-noexec
    route-up vpn_up.sh

now if i set the interface to tun0 in curl it use openvpn and if not the classic network interface

Post Reply