Adding static route based on a script

How to customize and extend your OpenVPN installation.
Post Reply
ofirule
OpenVpn Newbie
Posts: 5
Joined: Thu Aug 09, 2018 1:09 pm

Adding static route based on a script

Post by ofirule » Thu Feb 24, 2022 3:58 pm

In my VPN logic all of my client certificates have the folowing CN template:

name.number.mycompany.com
where number is between 2-65536

For each CN I add config file which looks like so:

Code: Select all

$ cat name.65501.mycompany.com
ifconfig-push 10.22.255.221 255.255.0.0
So basically based on the CN number area I configure the static ip in the relevant file,
conversion from number to ip logic:

Code: Select all

$ python3 -c "print('10.22.{}.{}'.format(*divmod(65501, 256)))"
10.22.255.221
Is there a way to do it dynamically in the config with a script or something else, instead of adding client config file everytime?

User avatar
TinCanTech
Forum Team
Posts: 10826
Joined: Fri Jun 03, 2016 1:17 pm

Re: Adding static route based on a script

Post by TinCanTech » Thu Feb 24, 2022 4:30 pm

You can use the dynamic file.

ofirule
OpenVpn Newbie
Posts: 5
Joined: Thu Aug 09, 2018 1:09 pm

Re: Adding static route based on a script

Post by ofirule » Thu Feb 24, 2022 6:31 pm

I don't know what is the dynamic file. May you please add a link or an example?

User avatar
TinCanTech
Forum Team
Posts: 10826
Joined: Fri Jun 03, 2016 1:17 pm

Re: Adding static route based on a script

Post by TinCanTech » Thu Feb 24, 2022 6:53 pm

See --ifconfig-push in the manual.

ofirule
OpenVpn Newbie
Posts: 5
Joined: Thu Aug 09, 2018 1:09 pm

Re: Adding static route based on a script

Post by ofirule » Tue May 31, 2022 2:36 pm

Added similar question with answer in the following link:
https://serverfault.com/questions/11021 ... n-a-script

Post Reply