Score:0

How to run a script in a OpenVPN server hosted in pfSense when client connects?

cn flag

I've got an pfSense 2.6 instance which hosts OpenVPN for clients. I'm testing with client version OpenVPN Connect 3.3.7 (2979).

There are some web endpoints with a dynamic IP addresses, so I can't push the routes easily via Custom options. I also don't want to redirect all the traffic via the VPN either.

I found out about allow-pull-fqdn, but that's not supported by OpenVPN connect versions 3.x, source: https://github.com/OpenVPN/openvpn3/issues/195

I'm now searching how to create a script to resolve DNS record and push the IP into client configuration.

The first option would be the best if the OpenVPN server would resolve the DNS record and push the route via script or some other means, because then I would not need to care about scripts on the clients.

Is there a way to do it like this?

The second option is to run a script on the clients. The client OS's can be Windows, Macs and Linux, so there's need to maintain different scripts.

I've been looking into client-connect option, but I can't seem to get it to work at all. I wrote a batch file vpn_push_routes.bat

echo 'test' > C:\Users\user\Documents\test.txt

I've added these lines into the client config file:

script-security 3
client-connect C:\\Users\\user\\Documents\\vpn_push_routes.bat

The OpenVPN Connect shows in the log that the lines are listed as UNUSED OPTIONS

[Mar 8, 2023, 18:27:20] UNUSED OPTIONS
1 [persist-tun]
2 [persist-key]
3 [data-ciphers] [AES-256-GCM:AES-128-GCM:CHACHA20-POLY1305:AES-256-CBC]
4 [data-ciphers-fallback] [AES-256-CBC]
6 [tls-client]
8 [resolv-retry] [infinite]
10 [nobind]
14 [auth-nocache]
20 [script-security] [3]
21 [client-connect] [C:\Users\user\Documents\vpn_push_routes.bat]

I'd be also okay with the second option. Could somebody help?

Score:0
cn flag

Seems that the issue with 2nd option was that the client being used was OpenVPN Connect 3.3.7. Documentation seems to be sparse how to use it with extra options.

With client version OpenVPN Community 2.6.1 the script worksby adding the below lines into client config file. Here's the reference manual for version 2.6.

script-security 2
up 'C:\\Users\\user\\Documents\\vpn_push_routes.bat'
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.