The computer is connected to the network, say 192.168.0.0/24. There is a VPN connection to another network 192.168.10.0/24.

How to make so that when connecting a VPN route is automatically added to the network 192.168.40.0/24?

I understand that it would be possible to do this:

route add -p 192.168.40.0 mask 255.255.255.0 <IP VPN> 

The problem is that - it changes with every connection.

    1 answer 1

    You must create a trigger to create a VPN connection. If it does not change my memory, then when a connection is established using Windows tools, an entry from the "RasClient" source with the corresponding Event ID number appears in the "Application" event log. You need to create a task to run route.exe with the necessary parameters. It is possible through the "Task Scheduler" snap-in. The created task must be launched from the user SYSTEM . To do this, it is covertly executed regardless of user registration and with the highest rights. When giving you an IP address, I think the gateway address is always the same on the VPN interface. So enter it as the IP VPN for the route command