How can I have different ip for differnt distrubutions on wsl2? - windows-subsystem-for-linux

I am running 5 different Ubuntu distro on wsl2 but all are having the same ip address.For example Ubuntu 18.04 and Ubuntu 20.04 are having the same ip. Is it possible to have different ips on each Ubuntu versions?

Full disclosure: This answer does not address networking between to wsl2 instances. Rather, it presents - as requested from a commenter - an alternative way to have two guest operating systems to each have their own IP address within a network that is "inside" the host OS.
The following allows for two VMs (rather than wsl2 instances) to have different IP addresses within a network within a host Windows 10 operating system:
Prerequisites in no particular order:
Disable the Hyper-V Windows Feature. This page describes a variety of ways to go about it, but I went the Control Panel route.
Install VirtualBox
Set up a network for the VMs to share:
Open VirtualBox
Click File > Preferences
Click Network
Click the icon with a plus sign (+) in it to add a new network
Create your VMs and connect them to this network
Create the VM and give it an operating system as you would otherwise
Shut down the VM
Select the VM in the main VirtualBox window, click the Settings/gear button
Click Network
Select NAT Network for "Attached to"
Select the name of the network you created above. (A sample that worked for me is below.)
Customize the overall network settings for the VMs
Return to main VirtualBox window > File > Preferences > Network
Click gear icon to edit the network
Click Port Forwarding
Enter details (such as the following, but modified for you needs) to direct traffic from local host to certain IP addresses/ports within this network

You can create new processes with new network namespaces, so you can achieve network isolation.
ip netns add net1
ip netns exec net1 ip addr add 192.168.99.10/24 dev sit0
ip netns exec net1 exec bash
Reference: https://blogs.igalia.com/dpino/2016/04/10/network-namespaces/

May you can try this solution: https://superuser.com/a/1715457/860784, with which I managed to get multiple IPs. And I can ping each other.
However, after reboot these IPs lost, and I still get my distros the same IP, which is exact the windows ip.
May you can sovle your problem and my problem. :)

Related

Windows Server 2019 - VMs on Hyper-V cant get network

I have some trouble with my windows server 2019 running Hyper-V, for the background my windows server run on an ESXI infra.
It is impossible for me to get any internet access nor domain access on my Hyper-V virtual machine, this is how my host configuration look like
Host network
For me all look good, but when I turn on my virtual machine this is what I get
VMs network
VMs ping
I can see the machine getting a IP from my DHCP server, but it is impossible for me to ping any of the gateway, DNS.
My DHCP
This is how my virtual switch look like
vSwitch Hyper-V
And if needed my Ipconfig of my Windows server Hyper-V host
Hyper-V host network
I think that i have now tried everything I could, I don't see why my machine can get a DHCP IP, but can't communicate with any of my server.
I already have a topic posted on SpiceWorks (https://community.spiceworks.com/topic/2326264-hyper-v-wont-provide-internet-access-on-my-virtual-machine?page=1#entry-9231547), the last answer suggested that the problem came from my vSwitch on Hyper-V, but even after recreating a new one I can't get anything.
If you have any idea that can help me to achieve my configuration even the slightest one I'll gladly take it.
First thing I would like to ask, you are doing a Double Nested Virtualization, meaning: [ESXi] is the BareMetal Hypervisor, then inside of this Host you have at least 2 VMs, one name "SRVPARDC001" & the Hyper-V VM named "TESTHYPERV" , and inside this last one you have another VM called "VDI-Master" , if this is correct, you are asking:
*Why is VDI-Master, not getting internet, when SRVPARDC001 has leased an IP address ( 192.168.1.118) ?
My question is, why does the ipconfig output for VDI-Master show IP 192.168.1.121 , which per your DHCP, should be leased to the Desktop
Would it be possible to use a different subnet for the Virtual Switch inside the Hyper-V , to eliminate routing/dhcp issues?
My impression is that there is an issue on how the virtual switch is configured on the TESTHYPERV vm, since that virtual switch should be allowing the traffic upstream to the ESXi host and then out via your gateway/router/firewall device.

Remote access Jupyter notebook from Windows

I usually access Jupyter notebook running on Linux from Mac OS X via port forwarding like following:
https://coderwall.com/p/ohk6cg/remote-access-to-ipython-notebooks-via-ssh
Is it possible to do similar thing from Windows 10 instead of Mac OS? I guess putty or WSL offer one.
https://www.akadia.com/services/ssh_putty.html
https://superuser.com/questions/1119946/windows-subsystem-for-linux-ssh-port-forwarding
You can create an SSH tunnel to connect to the Jupyter Notebook or Jupyter Lab web interface using PUTTY on windows.
Download the latest version of PUTTY
Open PUTTY and enter the server URL or IP address as the hostname
Now, go to SSH on the bottom of the left pane to expand the menu and then click on Tunnels
Enter the port number which you want to use to access Jupyter on your local machine. Choose 8000 or greater (i.e. 8001, 8002, etc.) to avoid ports used by other services, and set the destination as localhost:8888 where :8888 is the number of the port that Jupyter Notebook is running on. Now click the Add button, and the ports should appear in the Forwarded ports list.
Click the Open button to connect to the server via SSH and tunnel to the desired ports.
In the PUTTY terminal, run Jupyter, where the default port is 8888
jupyter lab --no-browser or jupyter-notebook --no-browser
Copy the server path into the browser on your local system and navigate to the notebook
http://localhost:8888/lab?token=... or http://127.0.0.1:8888/lab?token=...
Note:
If running remotely to your employer, a VPN connection will probably be required.
As an addendum to this answer, this screenshot shows how putty config looks like:
On the Linux machine, I then start Jupyter with:
jupyter notebook --no-browser --port=8889
Finally, on the windows (or any remote machine) I enter localhost:8888 in the browser.
It asks for the token, that is provided at the shell of the Linux machine.
--
Note which port refers to which machine, I have the notebook on port 8889, the browser calls it at localhost:8888
I solved this problem by myself. My solution is using Windows Subsystem for Linux (WSL). This offers (virtual?) Linux console like Ubuntu. I just use ssh with -L option on it.
Follow the steps below.
step1- Download putty.
step2- Insert ip address or hostname.
step3- Go to SSH and expand.
step4- Add address of jupyter-notebook to destination column ex: localhost:6666. Add local port such as 8000 to source and press add button. Then connect, it should work.
I wanted to use the VPN Server feature of my cable box to enable remoting into my network, especially to run jupyter notebook. For my situation, probably not quite the same as anyone elses, this works fine.
On the cable box, be sure to enable the VPN Server and enable external access.
On the remote Windows 10 computer, add a PPTP VPN specifying cable box's external IP. Connect to the VPN. Verify you can access the network. e.g. You should be able to see the cable box's webpage.
On the Jupyter serving computer, in Windows Defender Firewall, you need to create a new Inbound Rule for a Port.
3.1. General-> Enabled, Allow the connection
3.2. Protocols and Ports-> TCP, 8888
3.3. Scope-> Private
On the Jupyter serving computer, invoke Jupyter (e.g 192.168.0.1, port 8888):
jupyter-notebook --ip 192.168.0.1 --port 8888 --no-browser
On the remote computer, you should now be able to access your Jupyter server by browsing to http://192.168.0.8:8888/tree

Cannot do Vagrant ssh after Vagrant up on windows Machine

I am building a sample vagrant box to install Jenkins and push it to atlas cloud.Please find below the steps that I followed.
Vagrant init ubuntu/trusty64
and the normal command to initialize the vagrant machine.
vagrant up
After this if i type command to ssh into the machine
vagrant ssh
It gives me error saying please increase timeout and so.
The main question is how can I ssh into the newly created vagrant machine.
To understand this, I have to go through all the basics. Please find below my findings.
Not attached
In this mode, VirtualBox reports to the guest that a network card is present, but that there is no connection -- as if no
Ethernet cable was plugged into the card. This way it is possible to "pull" the virtual Ethernet cable and disrupt the connection, which can be useful to inform a guest operating system that no network connection is available and enforce a reconfiguration.
Network Address Translation (NAT)
If all you want is to browse the Web, download files and view e-mail inside the guest, then this
default mode should be sufficient for you, and you can safely skip the rest of this section. Please note that there are certain limitations when using Windows file sharing (see Section 6.3.3, “NAT limitations” for details).
NAT Network
The NAT network is a new NAT flavour introduced in VirtualBox latest versions.
Bridged networking
This is for more advanced networking needs such as network simulations and running servers
in a guest. When enabled, VirtualBox connects to one of your installed network cards and exchanges network packets directly, circumventing your host operating system's network stack.
Internal networking
This can be used to create a different kind of software-based network which is visible to selected virtual machines, but not to applications running on the host or to the outside world.
Host-only networking
This can be used to create a network containing the host and a set of virtual machines, without the need for the host's physical network interface. Instead, a virtual network interface (similar to a loopback interface) is created on the host, providing connectivity among virtual machines and the host.
Generic networking
Rarely used modes share the same generic network interface, by allowing the user to select a driver which can be included with VirtualBox or be distributed in an extension pack.
At the moment there are potentially two available sub-modes:
UDP Tunnel
This can be used to interconnect virtual machines running on different hosts directly, easily and transparently, over existing network infrastructure.
VDE (Virtual Distributed Ethernet) networking
This option can be used to connect to a Virtual Distributed Ethernet switch on a Linux or a FreeBSD host. At the moment this needs compiling VirtualBox from sources, as the Oracle packages do not include it.
Out of these, only NAT and Host-only network is important.So, to solve this issue, I modified the predefined Vagrant file with the following code.
jenkins.vm.provider "virtualbox" do |vb|
jenkins.vm.network "private_network",ip:'192.168.56.5',:adapter => 2
jenkins.vm.hostname = 'jenkins.ci'
vb.name = "Jenkins"
end
Here, I have created a private network with static Ip and also, I specified the adapters count to use 2. The Private adapter is Host-only adapter and 1st adapter which is default one is NAT.

Accessing VM's terminal using putty in host OS?

I am working on a project in which we logon to client's machine using Cirtix receiver. The machine which we connect to using Citrix receiver is basically a Windows 7 machine. Once we are in the client's windows box, inside that we have virtual box, in which VM has been added and which has all the needed software for us to do the development; for example JBOSS, database etc.
In the host machine (windows 7), we have putty, and using putty we sometimes login to the VM (i.e. terminal). The confusion which I have is as below:
We login to the VM terminal using IP address: 127.0.0.1. This is where my confusion is. 127.0.0.1 normally is the IP address with which we can refer to the current machine; so how using this IP address we are able to connect to the VM which is added to the virtual box? Doesn't the VM which is in virtualbox has its own IP address with which we can connect to? Or is there some concept which I am not aware of.
Can anyone help me in understanding this? I am not well versed with virtualization, so for the gurus this might be a naive question.
Every VM will have their uuids so to access the VM inside virtualBox or any hypervisor for that matter. so you can use that particular VM uuid and u should be able to console to that VM.
in virtual box try below
You can use: VBoxManage list vms to list all currently registered VMs with their settings, names and UUIDs.
Once you know the UUID you can also start a vm by:
VBoxManage startvm which is essentially same as: VBoxManage startvm "Name-of-vm"
Also Vm has two interfaces one loopback which will have an address of 127.0.0.1 and the rest of the interfaces so to access the VM with particular ip you need to assign an IP to that VM interface and than try with that IP.Also you might have that port 22 open for that loopback ip so may be that is the reason you are able to connect on loopback
I hope this answers your question

how do i reach apache on a vitualbox machine

I am trying to run a virtual LAMP machine on my windows 7 for dev purposes. But i cant figure out how to reach the apache from the host windows 7 system. I did an ifconfig and tried the ipaddress, but to no avail.
If you set virtualbox to use bridged (regular) networking then it's no different from any other machine on the LAN, if you set host only then you can still call it - you just need to know it's IP address.
See http://opensourceexperiments.wordpress.com/2008/04/18/virtualbox-case-study-making-host-only-networking-work-between-two-ubuntu-guest-os-virtual-machine-on-windows-vista-host/
You will need to set the networking mode of your VM in virtualbox.
Bridged will allow others on the LAN
to access your VM.
Host-Only will allow your host and
any other VM's also configured as
host-only to access one another.
Virtual Box Neworking
If you look at the link you will have many different options on the type of networking you can do.
as mentioned earlier, I recommend either:
Bridged networking that makes the box look like an other computer on your network. They you may use ipconfig on the box or verify your router logs.
Host-Only networking is where your windows 7 will be its own network between the box and windows and then you may use the Ip address from ipconfig.