Page 1 of 1

Get the server IP without pulling all the routes

Posted: Thu Jan 28, 2016 2:58 pm
by fra87
Hi all
I'm just a kind-of-noob, since I started using OpenVPN just one week ago, so if the solution is simple.. Well, be merciful ;)
I setup a system where there is one server (with IP address 10.8.0.1) and multiple clients connecting to it through a tun interface.
Now, on the clients I can't pull the route from the server, since they need their own routing policies. What I need, however, is to know the server IP address (the 10.8.0.1) on the clients, since I need to configure a static route to it. Of course I can just hardcode the 10.8.0.1, but I preferred an automatic way to handle this.
Unluckily in the connection scripts I can't find it (for instance on the client which has an IP 10.8.0.14 the remote IP is 10.8.0.13.

Where can I find it?

Best regards

Re: Get the server IP without pulling all the routes

Posted: Thu Jan 28, 2016 7:45 pm
by Traffic
Try --topology subnet in the server.

Re: Get the server IP without pulling all the routes

Posted: Tue Feb 02, 2016 12:05 am
by fra87
Hi
Thank you for your help. Unluckily the topology subnet does not suit my needs because I need to be able to open multiple openvpn sessions towards the same server (each going through a different interface).

In the end I solved by creating a custom script to intercept iproute commands (and make OpenVPN use it through the iproute option). Then I enabled route-pull on the client, so the route commands are passed to the script.
In the script I filter the route commands and so I can find the gateway IP. All the non-route commands (add, link, del ...) are forwarded to ip route.