Page 1 of 1

Adding static route based on a script

Posted: Thu Feb 24, 2022 3:58 pm
by ofirule
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?

Re: Adding static route based on a script

Posted: Thu Feb 24, 2022 4:30 pm
by TinCanTech
You can use the dynamic file.

Re: Adding static route based on a script

Posted: Thu Feb 24, 2022 6:31 pm
by ofirule
I don't know what is the dynamic file. May you please add a link or an example?

Re: Adding static route based on a script

Posted: Thu Feb 24, 2022 6:53 pm
by TinCanTech
See --ifconfig-push in the manual.

Re: Adding static route based on a script

Posted: Tue May 31, 2022 2:36 pm
by ofirule
Added similar question with answer in the following link:
https://serverfault.com/questions/11021 ... n-a-script