Get the server IP without pulling all the routes

Scripts with setup, destroy, and modify routing tables and firewall rulesets for client connections.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
fra87
OpenVpn Newbie
Posts: 2
Joined: Thu Jan 28, 2016 2:48 pm

Get the server IP without pulling all the routes

Post by fra87 » Thu Jan 28, 2016 2:58 pm

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

User avatar
Traffic
OpenVPN Protagonist
Posts: 4066
Joined: Sat Aug 09, 2014 11:24 am

Re: Get the server IP without pulling all the routes

Post by Traffic » Thu Jan 28, 2016 7:45 pm

Try --topology subnet in the server.

fra87
OpenVpn Newbie
Posts: 2
Joined: Thu Jan 28, 2016 2:48 pm

Re: Get the server IP without pulling all the routes

Post by fra87 » Tue Feb 02, 2016 12:05 am

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.

Post Reply