Manually creating route and OpenVPN server IP
Posted: Thu May 02, 2013 10:27 pm
Hi,
I'm currently using OpenVPN on a client station, which is a Debian 6 server.
I've managed to successfully connect on the server without a problem, but the server is pushing routes on my client, which "overrides" my default route and force all the packets to be routed by the VPN, which is not what I want.
I want to force specific packets / application to use the VPN, and the other one my "normal" internet line. I've read several tutorial, and I think I'll manage to setup this configuration, using iptables, and ip rule. So I've created another route table in my system, and I have refused the route pushed by the server, using the "route-noexec" option.
My plan is to create manually my routes using a script ("route-up" option) and "ip route" command, but there's a problem : my OpenVPN server "remote" option is a DNS name, which resolves to 6 different IPs addresses. When I connect to the OpenVPN server, OpenVPN resolves the DNS name, and pick randomly one of the six IPs.
How can I know which IP is being used to contact the server ?
the "remote_{n}" environmental variable is filled with the DNS name of the server, not the IP. And if I resolves myself the DNS in order to get the server IP, I have five chances out of six to get the wrong IP.
The only place I know where the IP is declared is in the log. I can parse it and retrieve the IP, but I'm looking for a more elegant solution.
Thanks for your help.
Sterfield
I'm currently using OpenVPN on a client station, which is a Debian 6 server.
I've managed to successfully connect on the server without a problem, but the server is pushing routes on my client, which "overrides" my default route and force all the packets to be routed by the VPN, which is not what I want.
I want to force specific packets / application to use the VPN, and the other one my "normal" internet line. I've read several tutorial, and I think I'll manage to setup this configuration, using iptables, and ip rule. So I've created another route table in my system, and I have refused the route pushed by the server, using the "route-noexec" option.
My plan is to create manually my routes using a script ("route-up" option) and "ip route" command, but there's a problem : my OpenVPN server "remote" option is a DNS name, which resolves to 6 different IPs addresses. When I connect to the OpenVPN server, OpenVPN resolves the DNS name, and pick randomly one of the six IPs.
How can I know which IP is being used to contact the server ?
the "remote_{n}" environmental variable is filled with the DNS name of the server, not the IP. And if I resolves myself the DNS in order to get the server IP, I have five chances out of six to get the wrong IP.
The only place I know where the IP is declared is in the log. I can parse it and retrieve the IP, but I'm looking for a more elegant solution.
Thanks for your help.
Sterfield