DNS not working in Bash (Ubuntu) on Windows using VPN

9

6

I've just started testing out "Bash on Ubuntu on Windows", and I like it!

Just, the problem is that I need to use VPN in order to access our backend and developer servers. And when trying to (for example) ssh to our dev server with the Windows Bash shell it cannot resolve the hostname.

Note that I am able to ssh using the ip-address, and also these hostnames work just fine elsewhere in Windows. Like with putty, regular cmd, File Explorer etc.

I did also check the /etc/resolv.conf and can see our work nameserver listed there.

From here on my networking skills fall short, especially with Linux, so please help :D

Aleksander Akerø

Posted 2016-09-21T15:36:37.587

Reputation: 191

I've just hit on the same issue. Did you manage to resolve the issue elsewhere? – Hugh – 2017-09-26T14:44:18.017

Answers

1

It's a routing problem, not a bug of WSL. It's very likely that your local subnet is the same as the remote subnet. And I assume you use the bridged VPN.

I have encountered the same issue. I use OpenVPN to connect my office(remote) and my home(local). The two subnets are both 192.168.1.0, which is the most common one where you would find on many routers.

I eventually resolved the issue with the following config. My goal is to use tun in order to reduce overhead and only redirect the traffic where the destination is at the office. However, this would also work with the bridged VPN.

;make the dhcp-option works on Windows 10.
script-security 2
;do not accept any pushed route command.
route-nopull
;make sure the connection still go through my home router. This line may not be necessary. You can try to remove this line and see it the VPN works.
route 192.168.1.1 255.255.255.0 net_gateway
;redirect the traffic where the destination is within the 192.168.1.0 subnet to OpenVPN gateway.
route 192.168.1.128 255.255.255.128
route 192.168.1.0 255.255.255.128
;set the DNS server which is in the office
dhcp-option DNS 192.168.1.254
dhcp-option DNS 192.168.1.253
dhcp-option DOMAIN my.company.domain

Jason Chueh

Posted 2016-09-21T15:36:37.587

Reputation: 111

0

This doesn't solve the problem with the DNS not working, but it's a workaround that makes it seem like it's working.

You can edit your hosts file (at /etc/hosts) and add an entry for the hostname that you want to use.

Add an entry that has the IP address followed by a space and the hostname.

123.456.1.1 target.host.net

Note, you'll need to sudo your edit command. sudo vi /etc/hosts

For me, the edit sticks around across bash shell sessions. I'm assuming it's a bug that Microsoft will hopefully fix in the future. For now, I just use this workaround.

Steve M

Posted 2016-09-21T15:36:37.587

Reputation: 9

-1

I have the same problem. I temporarily edited /etc/resolv.conf with only one nameserver and one search domain (for the VPN network) and it resolved hostnames on that network. This change is not persistent, so exiting and restarting Bash on Ubuntu on Windows will restore /etc/resolv.conf to its default settings.

Paul

Posted 2016-09-21T15:36:37.587

Reputation: 1

1"but would really like to know how to properly set up the network interfaces for Bash on Ubuntu on Windows so that establishing a VPN connection in Windows automatically configures DNS." - You should remove this commentary from your answer. – Ramhound – 2017-01-08T21:26:09.603