Dê uma olhada aqui:
D) Bonus option! openvpn also has a up /down directive that allows you to launch a script on connect to vpn this can allow you to do anything you want really. setting dns, routes etc. But it requires you to store the commands in another file.
So if you had the following to your openvpn client config file
script-security 2
up run-stuff-after-vpn-connect.sh
create a file named run-stuff-after-vpn-connect.sh (make sure it has execute permissions. And add:
/bin/sh
route add -net 172.16.0.0/24 dev tun0 will add the route as soon as the tunnel is up
Então, basicamente, você coloca sua rota em um arquivo sh, por exemplo my_route.sh (suponho que 192.168.193.1 seja seu endereço IP local OpenVPN GW)
#!/bin/sh
/usr/sbin/ip route add 20.20.20.0/24 via 192.168.193.1 dev tap0
adicione ao arquivo de configuração do seu cliente OpenVPN
up /your path to/my_route.sh
Pode não funcionar, então você também pode adicionar a rota através da configuração de inicialização do systemd
[Unit]
Description=OpenVPN connection to %i
[Service]
Type=forking
ExecStart=/usr/bin/openvpn --cd /etc/openvpn --config /etc/openvpn/%i.conf --daemon openvpn@%i
ExecStartPost=/your path to/my-add-route.sh
ExecStop=/your path to/my-remove-route.sh
[Install]
WantedBy=multi-user.target