Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to setup private network #40

Open
Agus-Wei opened this issue Apr 28, 2023 · 5 comments
Open

How to setup private network #40

Agus-Wei opened this issue Apr 28, 2023 · 5 comments

Comments

@Agus-Wei
Copy link

Is it possible to setup private network through Vagrantfile?

@leifliddy
Copy link

leifliddy commented May 3, 2023

There's been a couple issues created on this topic.
#33
#36

@ppggff
Copy link
Owner

ppggff commented May 8, 2023

I have done some research for this problem on MacOS:

  • qemu add a new type of network 'vmnet-host|vmnet-shared|vmnet-bridged' based on MacOS vmnet.framework
    • vmnet-shared:
      allows the guest to communicate with other guests in shared mode and
      also with external network (Internet) via NAT. Has (macOS-provided)
      DHCP server; subnet mask and IP range can be configured;
    • vmnet-host:
      allows the guest to communicate with other guests in host mode.
      By default has enabled DHCP as vmnet-shared, but providing
      network unique id (uuid) can make vmnet-host interfaces isolated
      from each other and also disables DHCP.
    • vmnet-bridged:
      bridges the guest with a physical network interface.
  • the vmnet-shared and vmnet-host look like a good match to the public and private of vagrant network

But there still have some problem:

  • it needs root to run the qemu command (https://gitlab.com/qemu-project/qemu/-/issues/1364)
  • it doesn't support port forward by itself (need to work with user network together, you have 2 interfaces)
    • some box doesn't support 2 interfaces very well, and it's hard to control the order of these interfaces
  • it's hard to use a pre-defined ip address

Also there is a third party program socket_vmnet from the lima project:

  • it's also based on the MacOS vmnet.framework (so it has the same advantages and disadvantages as above)
  • qemu connect to socket_vmnet to make the network works
  • it needs root to run, by you can run the qemu command without root

I prefer to use qemu directly, maybe use sudo to handle the root problem.
I will try to make it work with vagrant's network config soon.

@andronat
Copy link

Any examples on how can we run a qemu VM with (e.g.) vmnet-bridged? Because when I tried to add it on the following args:

    qe.net_device = 'virtio-net-pci'
    qe.extra_netdev_args = 'vmnet-bridged=on,ifname=en0'

I got the following error, which suggests the plugin is pre/appending various other arguments that are not compatible with the vmnet arguments:

Stderr: qemu-system-x86_64: -netdev user,id=net0,hostfwd=tcp::50022-:22,vmnet-bridged=on,ifname=en0: Invalid parameter 'vmnet-bridged'

@unixerius
Copy link

@andronat , @ppggff already said this plugin hasn't been adjusted to work with vmnet-* yet.

Like you, I would love to use these solutions, but it's not possible yet.

@unixerius
Copy link

With regards to your post of May 8th, I feel that you should wait for Qemu to build in the required support for non-privileged users.

They themselves have already identified that their biggest hurdle is that their software isn't flagged by Apple as being permitted to use the com.apple.vm.networking entitlement. The main reason for this is A) that they haven't requested it and B) that their brew install does a build from source code. source

That seems like something they as project should be able to work on. Until they've done so, I would not recommend that you build in a sudo workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants