Answer the question
In order to leave comments, you need to log in
How to write script to add VPN route?
Good afternoon colleagues. Immediately on the shore I will explain the problem in more detail.
1. Configure VPN for N number of wheelbarrows outside the perimeter (users have their own PCs)
2. Add routes to their own machines.
And so, in general, everything is clear with point No. 1, who doesn’t know, I’ll explain (who knows, please read to the end)
Set up the required type of VPN on the reference wheelbarrow, then go along the path C:\Users\USERNAME\AppData\Roaming\Microsoft\ Network\Connections\Pbk and pick up rasphone.pbk (in fact, all our VPN connections are located in it), open the txt editor, delete extra (if more than one connection is configured) profit, you can send it to users. Clicked-started the session, clicked again-closed. Convenient, all settings are saved (including remote network gateway)There is a cool VPN, but the subnets are different and with the unchecked use a remote network gateway, nothing works (Mikrotik Gateway, I still don’t understand why it doesn’t work, everything works on Keenetic (office of 10 people). It doesn't matter, we add routes manually. CMD from the admin drove: add -p 192.168.100.0 mask 255.255.255.0 192.168.101.1 earned, 1s works litsuhi issues, balls work fine, reboot - does not work. Ok, let's fix the metric. CMD -> route print look (with a running connection) we need the metric to be equal to 1 right?-right. We write route add -p 192.168.100.0 mask 255.255.255.0 192.168.101.1 metric 1 if (we put the number dropped from the route print 1 command, the first column in my case is called ITS ) we enter route add -p 192.168.100.0 mask 255.255.255.0 192.168. 101.1 metric 1 if 58
Reboot, it works. Cool! But you can’t explain to users, but it will take a long time to connect to each to each. Hence the question:
Is there a way to automate? Perhaps a script that would create the desired type of VPN and forward routes by changing the VPN connection metric or without VPN settings, just a script to forward the route with a change in the metric, so that the user can send the connection file (s) and a script with a body like if metric > 1 then metric = 1 (not competent in writing scripts)) Thanks for the tips.
Answer the question
In order to leave comments, you need to log in
change the metric in the same file
IpInterfaceMetric=0
to the desired one
. It is not clear with routing, since it is not clear what networks you have and what routes you need.
But if you do not use the range 192..168 for your networks, everything will work with routing by itself.
Windows, oddly enough, has classful routing for VPNs. that is, the route itself is added for 192.168.xxx.0/24
and if you use, for example, 10.xxx.yyy.0, then the route 10.0.0.0/8 will be added by itself
The batch file and in the scheduler, when the client logs in ...
I really have a different batch file at login, in which the openVPN session rises, then a pause (so that the connection is established), and adding the route in the same place ...
By the way, the metric has nothing to do with it, if there networks are not the same
On Mikrotik, it did not work automatically, because for him it is a "left" network, he must explicitly indicate whether to route it or not. And zyukhel immediately throws everything into routing, and don’t care that it may be inappropriate or unsafe)
Mikrotik also clings to this VPN? then you can just specify the route directly on it ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question