Page 1 of 1

Resolve Hostnames Over VPN

Posted: Mon Oct 19, 2015 3:54 am
by Isonite
I have an OpenVPN server running, and I can connect to it and ping its IP address without problems. However, I cannot ping its hostname and have my remote machine resolve the hostname to an IP address. For example, "ping 10.8.0.1" works, whereas "ping hostname" (where hostname is the name of the machine, and can be used to ping it on the local network) does not work.

Any insights anyone might have as to the cause of this would be very helpful. Thanks.

My client config is as follows:

client
dev tun
proto udp
remote example.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ns-cert-type server
comp-lzo
verb 3

My server config is as follows:

port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh2048.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
client-to-client
duplicate-cn
keepalive 10 120
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3

Re: Resolve Hostnames Over VPN

Posted: Mon Oct 19, 2015 11:21 am
by Traffic
Resolving hostnames relies on DNS which has nothing to do with OpenVPN.
Isonite wrote:For example, "ping 10.8.0.1" works, whereas "ping hostname" (where hostname is the name of the machine, and can be used to ping it on the local network) does not work.
What DNS server does your client use ?

Re: Resolve Hostnames Over VPN

Posted: Mon Oct 19, 2015 3:23 pm
by Isonite
I am not using any DNS servers other than the default ones for my ISP.

I should've clarified: I'm trying to resolve the names of other clients connected to the VPN.
I was under the impression that there might be a way to resolve hostnames without specifying a DNS server, such as over the Address Resolution Protocol on the local area network (or in this case, the VPN connection). Is this possible using TUN, or do I need to use TAP?

I have tried using "dhcp-option DNS 10.8.0.1" in the client config file, but that does not solve the problem.

Re: Resolve Hostnames Over VPN

Posted: Mon Oct 19, 2015 4:23 pm
by Traffic
Isonite wrote:I am not using any DNS servers other than the default ones for my ISP
Public DNS servers such as your ISP or google 8.8.8.8 et al have no knowledge of your private LAN machines or your VPN clients, so DNS will not work that way.
Isonite wrote:I have tried using "dhcp-option DNS 10.8.0.1"
For that to work you must run your own private DNS server.

You can also consider your OS hosts file to hold static names.

Re: Resolve Hostnames Over VPN

Posted: Mon Oct 19, 2015 6:05 pm
by Isonite
Thank you for your responses, Traffic.

Does that mean there is no way to dynamically resolve the hostnames of other machines when I'm connected through OpenVPN? I can resolve the hostnames of machines on my LAN, is there a way to do this with OpenVPN?

I figured that, if I have two machines (e.g. client1 and client2) connected to the same OpenVPN server, and I have client-to-client enabled in the server config, I'd be able to go to client1 and enter "ping client2" and it would work.

Re: Resolve Hostnames Over VPN

Posted: Mon Oct 19, 2015 9:53 pm
by Isonite
Update: I tried using TAP mode instead of TUN mode and I was able to resolve the hostnames of other clients on the VPN connection. I'm assuming this is just not possible with TUN.