1

I have a remote server that I am connecting to via OpenVPN. The OpenVPN-Server is configured not to forward ipv4 packages, so the "internet-traffic" does not go through the server.

Now I would like to assign a single URL to an IP address within the network. So for example: Whenever I am connected to the VPN and I enter random.org in my browser it redirects me to 10.8.42.12 within my VPN-Subnet.

I don't know, if this is possible or advisable? I have searched for a solution, but have not found one. Maybe because I am not using the correct terminology?

Any help or comments appreciated. Thanks! :)

3 Answers 3

1

You need to set a DNS A record somewhere, either on your VPN network or another network to which the clients can reach.

If you have a DNS server on the VPN network (or a network routable from the vpn connection) then you can configure openVPN to push DNS server addresses down to the clients so that when they connect, DNS's requests will go to the server you have specified that contains the A record you need. This set up means that the URL will only resolve to that IP when clients are connected to the VPN.

See this:

https://openvpn.net/index.php/open-source/documentation/howto.html#dhcp

EDIT:

I forgot to mention that consideration must be taken when changing out client DNS settings. The clients cache may still contain the lookup in which case you must look at setting the TTL on the A record so that it expires quickly.

0

use hosts file as in

10.8.42.12 example.org

or add entry to DNS server. create file with (e.g.) contents modifying the ns1.exampledns.com to point to a valid address

; Zone file for example.org
$TTL    3600
$ORIGIN example.org
@       IN      SOA     ns1.exampledns.com.    root.example.org. (
                                                     2012033101         ; Serial
                                                     3600         ; Refresh
                                                     1800         ; Retry
                                                     604800         ; Expire
                                                    43200 )       ; Negative Cache TTL

                IN      NS      ns1.exampledns.com.
                IN      NS      ns2.exampledns.com.

@       IN      A       10.8.42.12
www     IN      A       10.8.42.12

then add zone to /etc/bind/named.conf.local

zone "example.com" {
                type master;
                file "/etc/bind/db.example.org.conf";
};
-1

Sure, the DNS solution as per tomstephens89 answer is one possible answer, but it works only if you type any domain name, and also that won't work if the client alter the DNS servers pushed by the server.

What do you really want is a solution, which is sometimes called Captive Portal. I am not strictly inside that topic, but SQUID which is a powerful HTTP proxy (which can be configured to be a transparent one - i.e. no configurations on client side needed) can help redirect the user to your page.

3
  • What you are referring to is a HTTP Proxy and yes these can be used for directing HTTP requests. However for this task, a simple DNS configuration would suffice rather than putting a proxy in place. You are correct in saying that the client is able change the pushed DNS settings. Aug 20, 2015 at 11:37
  • Thanks for noting my mistake - of course SQUID is an HTTP Proxy. I fixed that error. The solution with setting up a kind of a Captive Portal with the help of a HTTP proxy server can also reroute requests to IPs, not only to DNS, and is a more robust solution. But it is indeed not an easy setup. But this won't mess with the user DNS cache - if the user reconnects to a normal internet connection and doesn't clear it's DNS cache it can have problems because of DNS rerouting cached previously.
    – Evengard
    Aug 20, 2015 at 11:40
  • that is a fair point regarding the client DNS cache and I will edit my answer to indicate that if DNS is the chosen solution then consideration must be taken with the TTL on the record. Aug 20, 2015 at 11:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .