11

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

2
  • I've just hit on the same issue. Did you manage to resolve the issue elsewhere?
    – Hugh
    Sep 26, 2017 at 14:44
  • I had similar issues an got them fixed, also posted my fixes here: stackoverflow.com/a/68573952/11473934
    – Kraego
    Jul 29, 2021 at 10:13

3 Answers 3

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
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.

-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.

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
    Jan 8, 2017 at 21:26

You must log in to answer this question.

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