I develop on Windows 10, so I use Hyper-V to run my Ubuntu VM. I don't want to mess around with complex networking whenever I go from a wired to wireless connection, so I just use the Default Switch.
Hyper-V sets the hostname for my development machine to nginx.mshome.net
I work on about 6 different website, so I have them all setup at hostnames like:
alpha.nginx.mshome.net
beta.nginx.mshome.net
gamma.nginx.mshome.net
For the longest time Hyper-V was pretty consistent with what IP address it assigns my VM, so I had these other hostnames just setup as static entries in my hosts file. I maybe had to go in and fix it every couple weeks, but that wasn't a big deal.
After installing the Windows 10 October 2018 Update, and the subsequent VPN x Blue Screen error that caused me to have to run netsh interface ip reset and netcfg -d, Hyper-V is now assigning a different IP address to my VM on virtually every boot.
I can't just set the VM to a static IP, because Hyper-V even changes the subnet for the Default Switch.
I tried setting up multiple network interfaces and forced dhclient to use a different hostname for each, but since they were all on the same subnet only one wanted to work on a time.
I need some kind of solution to either get Hyper-V to use and assign a consistent IP to my VM running on the Default Switch, or some kind of way to setup DNS aliases on Windows 10.
I've set this up using the Hyper-V Private Switch, using Internet Connection Sharing of my wireless connection to the Private Switch. I then just give the VMs a static IP, setup a host file entry, and go on my way. Since it's using ICS, that keeps the same subnet.
The only issue I have with this is that every so often Windows 10 forgets how to pass traffic over ICS. The cFosICS tool (https://www.cfos.de/en-us/cfosspeed/cfosics.htm) has a reset option that usually works. If not, cFosICS also lets you disable and reenable ICS via command line, so you can save a script to kick it into gear.
Related
It's not enough for me to bind WSL ports to localhost because I need to run applications in WSL which must be run in and from my local network. Attempt to switch WSL virtual switch to external in Hyper-V manager leads to Access-denied error (when wsl instance is running) with following big problems with host's and/or WSL's network as a result until I reboot the host. When WSL distro is not running WSL virtual switch is invisible in Hyper-V manager (Virtual switch manager).
I have 2 question and will be very appreciated if someone could help me with that:
Is it a normal behavior - having got problem with network attempting to configure WSL virtual switch directly? As I recall there were no such problems with Hyper-V virtual machines - maybe just short losing of connectivity, not more.
Is there a way to configure WSL such way so it starts with WSL external switch any time I run it? Files .wslconfig and /etc/wsl.conf look to be useless for this - I haven't managed to find the solution in google.
Yes you can convert it to external from Hyper-v Manager. Just start the Hyper-v Manager as Administrator
It is indeed possible to get this configuration to work with IPV4. This is quite tricky, as you need to act on the Network configuration to set an IP address in the external network, and this requires systemd to be enabled.
Install WSL and Ubuntu distribution
First ensure that you have WSL2 installed, and install it if this is not the case
https://learn.microsoft.com/fr-fr/windows/wsl/install
WSL documentation:
https://learn.microsoft.com/en-us/windows/wsl/
It is key to have Ubuntu installed for WSL2, as the KDE installation is not compatible with WSL1.
wsl --install Ubuntu-20.04
It is important to have a recent version of WSL (1.0 as of this writing), as it allows you to use systemd.
Configure networking
By default, WSL installs with NAT and a dynamic IP which changes each time WSL is restarted.
There are also very limited options to access network services brought by WSL, as only TCP ports can be proxied with netsh, not UDP ports. This causes all sorts of issues with X, as it is using UDP ports, and I have been totally unable to make X windows desktops work, despite HOWTOs online claiming success.
If you need additional tools, now is the time to install them, as you are going to lose network connectivity for some time.
apt install net-tools
Change from internal to external network (Hyper-V manager)
You need to open Hyper-V manager and go to the virtual switch management. There is a WSL switch which by default is configured as “Internal network”. You need to change it to “External network”.
You also need to select which physical adapter you are going to connect to, Ethernet or Wifi.
At this point and until you finish network configuration, you no longer have any network connectivity.
Your virtual network card is now connected to the external network, but it is not configured, which we are going to do now by means of systemd.
Configure you virtual network card
From within WSL, edit file /etc/wsl.conf so that it contains:
[network]
generateResolvConf = false
[boot]
systemd=true
Create a file named /etc/systemd/network/26-fixed-ip.network containing (example):
[Match]
Name=eth0
[Network]
Address=192.168.1.60/24
Gateway=192.168.1.1
DNS=192.168.1.30
Select a fixed IP address in your external network range, and adapt the above parameters according to your case.
Configure DNS resolution
We have already instructed WSL not to generate resolv.conf each time it is started, as seen above.
It is now time to configure /etc/resolv.conf to contain:
nameserver 192.168.1.30
nameserver 192.168.1.5
domain xxxxxxxx.net
Check connectivity
Stop and start wsl (from a Windows cmd prompt):
wsl --shutdown
wsl
When wsl is restarted, it gets the fixed IP address, instead of a random one. You may ping any IP address and it works. You may also ping your ip address from another host on your LAN:
ping 192.168.1.60
Yes you can, but it seems to work only in IPv6 in my situation:
When I ran wsl --shutdown and opened Hyper-V Manager, the WSL switch appeared in Virtual Switch Manager, and can be successfully changed to external.
However, the IPv4 address could not be changed, and it's unable to access the Internet via IPv4 either. So I have to assign a NAT IPv6 network (fd68::/64 in my case) to make it work.
Maybe you should do some repair to your system if you can't reproduce this.
Note: if switch WSL is changed to external, your main adapter will become vEthernet (WSL) or something similar.
I'm using a Cisco client to connect to a VPN but also using Synergy (Symless) to connect to the machine. It works fine initially but will drop out after machine sleep (or sometimes seemingly randomly), then I have to restart the VPN connection. Not the end of the world, but it is irritating.
Are there any config changes I can do to Networks settings, VPN or Synergy to stop this dropping out?
Found this which I hope will fix it.
https://blog.lan-tech.ca/2013/02/21/access-local-and-vpn-network-simultaneously/
"you just need to add the local devices to the windows routing tables so that it knows to access them when the VPN is active.
See the windows “route” command – E.G. route -p add MASK 255.0.0.0 METRIC IF
To help discover what you need to use, disconnect from your VPN, make sure you can connect to your local device, then run a “route print” show the current active routes and find your device. (generally in the IPv4 Route Table)
It will also list the ‘Metric’ to use, and at the top of the listing is the “Interface List” which lists the network interfaces on your system. You’ll need to figure out which one to use. For example, I know my system has a gigabit network adapter and in the list I see a “Intel(R) Gigabit Network Connection” – bingo – that’s it. The first column is the interface id, 49 in my case.
The “-p” option makes your configuration persistent – meaning that it will be there again next time you boot.
SO, as an example, let’s say I want a local network share at 192.168.1.43 to be accessible to my machine while connected to the VPN, so I would add the route like so:
route -p add 192.168.1.43 MASK 255.0.0.0 192.168.1.1 METRIC 15 IF 49
Now if I run route print, I see this new route in the list of persistent routes for IPv4.
I turn my VPN back on, and instead of the device ‘disappearing’ as it normally does, windows can still find it because it is in the persistent route list."
I am using VMware Workstation on a Windows 10 machine to add a Ubuntu Server and a Windows Server VM. This is to complete a virtual networking (firewall packet filtering) exercise using GNS3. The goal is to have 3 separate networks routed using virtual CISCO routers so I really need to have the IP of machines explicitly set to simulate different networks.
All of this is fine and I can ping from the host to the machines and the machines to the host but I'd also like to somehow be able to access Internet through each of the machines.
When I use Internet Connection Sharing and specify a single virtual adapter it warns me and changes the IP range to 192.168.137.x which is not desirable. When I want to use ICS for both VMs I create a bridged connection and apply ICS to that but again it changes my IP settings.
Is there a way I can share my hosts Internet Connection with each of the machines but keep the IP addresses and ranges I require?
Or, do I have to approach this a completely different way?
BTW, I'm using the Network Adapter type of 'Host Only' rather than Bridged or NAT as I cannot explicitly set IP addresses on those options.
I was overthinking it.
Using VMware I simply had to add an additional device Network Adapter (under VM > Settings) with a type of NAT to enable the VM to share my host's Internet. Of course, the existing interfaces (with the explicitly set IPs) were kept in place so it did not affect my virtual networking environment.
First I must say that I have no idea what kind of problem it is (Ubuntu/Windows/vmware/secureW2), so I hope anyone can select the necessary information from this mess.
I am running an Ubuntu 15.04 guest on a Windows 10 host using the vmware Virtual Machine. The Ubuntu internet icon in the right hand corner claims that it has a (wired) connection, yet I can't browse or ping google. Windows 10 is successfully connected by wi-fi, vmware uses a bridged connection (automatic) and my router enables DHCP. I can successfully ping my router from within the VM (at least, I assume 192.168.1.1 still refers to my actual router, and not some virtual router). In windows I can see two network adapters running (VMnet1 and VMnet8), both of which say they're enabled but have no internet access. I tried installing the bridge protocol in them, I tried using NAT instead of a bridge, but all to no avail. I was still connected just a few days ago when I was at school, which makes me think SecureW2 (a program responsible for connecting me to the school wi-fi) could also be involved somehow.
Everyone thanks in advance!
Turns out it was DNS related, caused by Ubuntu and SecureW2. The /etc/resolv.conf file was set up specifically for the LAN at school, for which I blame SecureW2. I "solved" it by adding my router IP to (the top of) the name server list, though I know this is only a practical solution.
I'm running Apache etc (actually MAMP at the moment, but soon to be replaced by individual Apache, PHP, MySQL...) on my Mac, for testing my websites locally/offline.
I want to be able to test all my local sites (domains *.dev) from any and all of the following, without having to update the hots file on each device (some of which, such as un-rooted phones, don't even allow editing of the hosts file):
Obviously, my Mac itself...
Any device on any local network to which my mac is connected (My Mac doesn't necessarily always have the same IP address)
Any virtual machine running on my Mac (in Parallels) – primarily, various versions of Windows (my Mac does always have the same IP address on Parallels Shared Networking)
Now, I read that dnsmasq may be able to help, and have installed it on my Mac using Homebrew. I set it up to start on startup, and my dnsmasq.conf reads as follows:
address=/.dev/127.0.0.1
This has the effect of allowing any domain *.dev to work on my Mac itself, which is a start.
Next I tried to make it work in a Parallels VM by setting the DNS server to be the local IP address of my Mac. However, this doesn't work – because dnsmasq returns 127.0.0.1 as the IP for any lookup for *.dev, but of course this makes the VM look for the site on the VM itself, rather than on my Mac... which obviously doesn't work.
So I'm a bit stumped. Can anyone give me any tips? Is there a way to set up dnsmasq to do what I want, or should I be looking at another method?
Thanks!
I don't have any experience with Parallels but with Virtualbox you can set up a bridged network connection. I presume Parallels has something similar. This will set up an internal network (e.g. on 192.168.1.*) and you can probably assign fixed IP addresses to that. Like this you can give the Mac a fixed IP address which you can also use in your dnsmasq configuration - but you might want to have two TLDs for this so that .dev can keep pointing to 127.0.0.1 while .devel points to 192.168.1.xx.