containers / gvisor-tap-vsock

A new network stack based on gVisor
Apache License 2.0
247 stars 46 forks source link

win10 + hyperv + multipass + ubuntu #199

Open gianluca-sabena opened 1 year ago

gianluca-sabena commented 1 year ago

I create a vm with multipass https://multipass.run/ and ubuntu LTS on windows (hyperv) but I cant start ./vm because eth0 is present and I can't remove it. The presence of eth0 give me the error "eth0 prevent this program from run"

How can I run ./vm in my case?

Thank you

gianluca-sabena commented 1 year ago

OK, I can remove eth by removing network card from hyperv

I can't create a connection between vm and windows. What are the correct parameter to start gvproxy-windows.exe -debug?

gianluca-sabena commented 1 year ago

Can someone provide the correct parameters to start 'gvproxy-windows.exe' on windows and and './vm' in linux hyperrv vm?

cfergeau commented 1 year ago

I'm not sure gvproxy-windows.exe works together with vm, I've never used both :-/ You need to configure your hyperv VM to use hvsock, see the first answer to https://stackoverflow.com/questions/60696166/using-the-hyper-v-sockets-between-windows-host-and-linux-guest

gbraad commented 1 year ago

Can you provide all the steps you did to set this up. Eg, did you set the registry setting?

gianluca-sabena commented 1 year ago

@cfergeau What I wolud like to do is the same done by wsl-vpnkit https://github.com/sakai135/wsl-vpnkit but on a plain hyperv vm (without WSL)

I suppose gvproxy-windows.exe works together with vm look at https://github.com/sakai135/wsl-vpnkit/blob/main/distro/alpine.dockerfile

@gbraad I confirm, I set up the registry as described here https://github.com/containers/gvisor-tap-vsock#windows-prerequisites but no connection happen

vpnkit
cfergeau commented 1 year ago

I would first debug this using an intermediate tool either on the host (https://stackoverflow.com/questions/60696166/using-the-hyper-v-sockets-between-windows-host-and-linux-guest mentions hvc) or on the guest (netcat or socat) to make sure a connection can be established to the other end. Once you are able to create the vsock/hvsock connection, then you can try to get gvproxy/vm to communicate.

gianluca-sabena commented 1 year ago

Ok I did a test:

ncat
cfergeau commented 1 year ago

Then you can start vm in the VM, and see if it can connect to the host?

fengxx commented 5 months ago

I am able to verify windows hyperv setup, it is working the windows registry in Readme the Rock/blob/main/README.md?plain=1#L69) is critical and it is using port 1024, if you changed to other ports, you need update GUID accordingly

# 1024 hex code is 400, the first part of GUID
$service = New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\GuestCommunicationServices" -Name "00000400-FACB-11E6-BD58-64006A7986D3"
$service.SetValue("ElementName", "gvisor-tap-vsock")

gvproxy-windows.exe -debug -listen "vsock://00000400-FACB-11E6-BD58-64006A7986D3"

On linux

# make sure to restart linux vm after adding registry if they are started alreday
sudo modprobe hv_sock
gvforwarder -stop-if-exist none -url vsock://2:1024/connect #change 1024 to match port in guid
# view forwarded ports
curl http://192.168.127.1/services/forwarder/all
# add port forwarding
curl http://192.168.127.1/services/forwarder/expose -X POST -d'{"local":"127.0.0.2:9022", "remote":":22"}'

On windows

ssh 127.0.0.2 -p 9022