ppggff / vagrant-qemu

Use Vagrant to manage machines using QEMU. Test with Apple Silicon / M1 and CentOS aarch64 image
MIT License
408 stars 32 forks source link

private_network results in non private IP (10.0.2.15)... #33

Closed jayunit100 closed 1 year ago

jayunit100 commented 1 year ago

Hi qemu friends!

It appears that private_network doesnt work...

Do we us Slirp or Tap networking in qemu vagrant for private ips? I think we may need TAP based on https://wiki.qemu.org/Documentation/Networking

For cluster setups w multiple VMs.

in the following vagrant file https://github.com/kubernetes-sigs/sig-windows-dev-tools/tree/master-qemu , i added

    controlplane.vm.network :private_network, ip:"#{k8s_linux_kubelet_nodeip}"

But it appears machines are coming up with 10.0.2.15...

vagrant@controlplane:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
       valid_lft 86331sec preferred_lft 86331sec
    inet6 fec0::5054:ff:fe12:3456/64 scope site dynamic mngtmpaddr noprefixroute 
       valid_lft 86332sec preferred_lft 14332sec
    inet6 fe80::5054:ff:fe12:3456/64 scope link 
       valid_lft forever preferred_lft forever
jayunit100 commented 1 year ago

@ppggff , have you run privatE_network before succesfully on the vagrant provider? It appears to do a bridge network i think for me no mater what i enter for the network type

ppggff commented 1 year ago

This plugin use the default "user networking (SLIRP)", and the default ip address is 10.0.2.15. You can change the default ip address by using the extra_netdev_args config, see details in the readme file.

To use tap, vmnet-shared or other custom network, please try to add raw qemu arguments by extra_qemu_args config.

jayunit100 commented 1 year ago

Thanks ! I can try that.


qe.extra_netdev_args = 

"net=192.168.51.0/24,dhcpstart=192.168.51.10"

Im trying to adopt this now to see if that solves it for me

jayunit100 commented 1 year ago

ok it seems to work now via

https://github.com/kubernetes-sigs/sig-windows-dev-tools/pull/238/files

    winw1.vm.provider "qemu" do |qe, override|
      qe.vm.network "private_network", type: "dhcp", ip: "10.20.30.20"
      qq.arch = "x86_64"
      qe.memory = windows_ram
      # need for x86_64
      qe.machine = "q35"
      qe.cpu = "qemu64"

      # devices compatible with this box
      qe.net_device = "e1000"
      qe.drive_interface = "ide"
      qe.ssh_port = 50023

      qe.extra_netdev_args = "net=10.20.30.0/24,dhcpstart=10.20.30.20"

Maybe we could make it so that it did this by default if someone set the private_network ? that way it would work the same as other providers like virtualbox ?

jayunit100 commented 1 year ago

i think we can close this for folks wanting to use private_ip, see the above snippet