Open UriZafrir opened 1 year ago
I tried with your config, it works with the correct ip.
❯ vagrant ssh worker1
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-57-generic aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Mon Apr 17 07:52:33 UTC 2023
System load: 0.1181640625
Usage of /: 2.5% of 61.84GB
Memory usage: 10%
Swap usage: 0%
Processes: 105
Users logged in: 0
IPv4 address for eth0: 192.168.51.11
IPv6 address for eth0: fec0::5054:ff:fe12:3456
❯ vagrant ssh controlplane
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-57-generic aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Mon Apr 17 07:54:30 UTC 2023
System load: 0.013671875
Usage of /: 2.5% of 61.84GB
Memory usage: 10%
Swap usage: 0%
Processes: 106
Users logged in: 0
IPv4 address for eth0: 192.168.51.10
IPv6 address for eth0: fec0::5054:ff:fe12:3456
You can you ps -ef|grep qemu
to confirm that the network setting is in the command line of qemu, for example:
... /opt/homebrew/bin/qemu-system-aarch64 ... -netdev user,id=net0,hostfwd=tcp::50024-:22,net=192.168.51.0/24,dhcpstart=192.168.51.10 -drive if=virtio,format=qcow2 ...
I seem to encounter a similar issue 👀
I am using this example block from the README:
Vagrant.configure("2") do |config|
config.vm.box = "perk/ubuntu-20.04-arm64" # README uses debian/bullseye64
config.vm.provider "qemu" do |qe|
qe.extra_netdev_args = "net=192.168.51.0/24,dhcpstart=192.168.51.10"
end
end
However if I try to ping or SSH into it, it does not work:
vagrant ssh
works fine and ifconfig shows the correct ip address
Also the running qemu proccess looks fine to me:
Machine: Mac M1 Pro OS: Ventura 13.3 Vagrant version: Vagrant 2.3.4
Happy to provide additional infomation 😃
This is the expected behavior.
The ip address in the configuration file (192.168.51.10) is the internal address of the virtual machine. It's works like behind a NAT network. The port 22 is mapped as 50022 on the host (qe.ssh_port = "50022"
), so vagrant ssh
works.
To get more information about network of qemu, https://wiki.qemu.org/Documentation/Networking, we use user network by default.
Currently, this plugin doesn't support complex network config with vagrant gramma, but you can append qemu config to achieve same effect. What's your requirement? Maybe I could add more example or figure out new feature for that.
Oh, thank you for clarifying. What I am trying to achieve is making the VM run on a specific IP within my private network so I can access it by connecting to that IP from my host machine. Is that somehow possible?
EDIT: When using the virtualbox provider, I was able to achieve this by setting
config.vm.network "private_network", ip: "192.168.51.10"
However with this provider I discarded this due to the following warning during the startup log:
==> default: Warning! The QEMU provider doesn't support any of the Vagrant
==> default: high-level network configurations (`config.vm.network`). They
==> default: will be silently ignored.
Hi I am also on Mac M1. I am trying to bootstrap a Kubernetes cluster with one control plane and one worker node. @benjaminfayaz is getting the correct ip in the ifconfig command but I am not. could someone kindly explain what I am missing?
this is the output of ps aux | grep qemu. it seems the net=192.168.51.0/24,dhcpstart=192.168.51.10 part is not there for some reason.
/opt/homebrew/bin/qemu-system-aarch64 -machine virt,accel=hvf,highmem=on -cpu host -smp 2 -m 2G -device virtio-net-device,netdev=net0 -netdev user,id=net0,hostfwd=tcp::50022-:22 -drive if=virtio,format=qcow2,file=/Users//Tmp/vagrant/.vagrant/machines/controlplane/qemu/88gicSkM6KE/linked-box.img -drive if=pflash,format=raw,file=/Users//Tmp/vagrant/.vagrant/machines/controlplane/qemu/88gicSkM6KE/edk2-aarch64-code.fd,readonly=on -drive if=pflash,format=raw,file=/Users//Tmp/vagrant/.vagrant/machines/controlplane/qemu/88gicSkM6KE/edk2-arm-vars.fd -chardev socket,id=mon0,path=/Users//.vagrant.d/tmp/vagrant-qemu/88gicSkM6KE/qemu_socket,server=on,wait=off -mon chardev=mon0,mode=readline -chardev socket,id=ser0,path=/Users//.vagrant.d/tmp/vagrant-qemu/88gicSkM6KE/qemu_socket_serial,server=on,wait=off -serial chardev:ser0 -pidfile /Users//Tmp/vagrant/.vagrant/machines/controlplane/qemu/88gicSkM6KE/qemu.pid -parallel null -monitor none -display none -vga none -daemonize /usr/bin/ssh vagrant@127.0.0.1 -p 50022 -o LogLevel=FATAL -o Compression=yes -o DSAAuthentication=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /Users//Tmp/vagrant/.vagrant/machines/controlplane/qemu/private_key /opt/homebrew/bin/qemu-system-aarch64 -machine virt,accel=hvf,highmem=on -cpu host -smp 2 -m 2G -device virtio-net-device,netdev=net0 -netdev user,id=net0,hostfwd=tcp::50023-:22 -drive if=virtio,format=qcow2,file=/Users//Tmp/vagrant/.vagrant/machines/worker1/qemu/NMO8p1jyed4/linked-box.img -drive if=pflash,format=raw,file=/Users//Tmp/vagrant/.vagrant/machines/worker1/qemu/NMO8p1jyed4/edk2-aarch64-code.fd,readonly=on -drive if=pflash,format=raw,file=/Users//Tmp/vagrant/.vagrant/machines/worker1/qemu/NMO8p1jyed4/edk2-arm-vars.fd -chardev socket,id=mon0,path=/Users//.vagrant.d/tmp/vagrant-qemu/NMO8p1jyed4/qemu_socket,server=on,wait=off -mon chardev=mon0,mode=readline -chardev socket,id=ser0,path=/Users//.vagrant.d/tmp/vagrant-qemu/NMO8p1jyed4/qemu_socket_serial,server=on,wait=off -serial chardev:ser0 -pidfile /Users//Tmp/vagrant/.vagrant/machines/worker1/qemu/NMO8p1jyed4/qemu.pid -parallel null -monitor none -display none -vga none -daemonize grep qemu
As I see from my previous comment for some reason qemu won't accept the arguments for the private IP. Any ideas please?
@UriZafrir What version of the plugin do you use? And please try a full restart?
@ppggff found I was using 0.19. updated to 0.3.4. now working! thanks so much :))
another question please. As I understand as long as I don't use tap networking or socket I can't make the two communicate (Except port forwarding which I think is not the solution I am looking for) for example this: https://github.com/ppggff/vagrant-qemu/issues/33
So now I am trying to create a TAP network:
Vagrant.configure("2") do |config|
(2..3).each do |i|
config.vm.define "vm-#{i}" do |web|
web.vm.box = "perk/ubuntu-2204-arm64"
if i==2
web.vm.hostname = "master-node"
end
if i==3
web.vm.hostname = "worker1"
end
web.vm.network "private_network", type: "dhcp", ip: "192.168.51.#{i}"
web.vm.provider "qemu" do |qe|
qe.memory = "2G"
qe.net_device = "e1000"
qe.drive_interface = "ide"
qe.extra_netdev_args = "net=192.168.51.0/24,dhcpstart=192.168.51.#{i}"
end
end
end
end
I would appreciate your assistance.
this is the error I am getting:
Command: ["qemu-system-aarch64", "-machine", "virt,accel=hvf,highmem=on", "-cpu", "host", "-smp", "2", "-m", "2G", "-device", "e1000,netdev=net0", "-netdev", "user,id=net0,hostfwd=tcp::50022-:22,net=192.168.51.0/24,dhcpstart=192.168.51.3", "-drive", "if=ide,format=qcow2,file=/Users/urizafrir/Tmp/vagrant/.vagrant/machines/vm-3/qemu/_0-vRG5wfuI/linked-box.img", "-drive", "if=pflash,format=raw,file=/Users/urizafrir/Tmp/vagrant/.vagrant/machines/vm-3/qemu/_0-vRG5wfuI/edk2-aarch64-code.fd,readonly=on", "-drive", "if=pflash,format=raw,file=/Users/urizafrir/Tmp/vagrant/.vagrant/machines/vm-3/qemu/_0-vRG5wfuI/edk2-arm-vars.fd", "-chardev", "socket,id=mon0,path=/Users/urizafrir/.vagrant.d/tmp/vagrant-qemu/_0-vRG5wfuI/qemu_socket,server=on,wait=off", "-mon", "chardev=mon0,mode=readline", "-chardev", "socket,id=ser0,path=/Users/urizafrir/.vagrant.d/tmp/vagrant-qemu/_0-vRG5wfuI/qemu_socket_serial,server=on,wait=off", "-serial", "chardev:ser0", "-pidfile", "/Users/urizafrir/Tmp/vagrant/.vagrant/machines/vm-3/qemu/_0-vRG5wfuI/qemu.pid", "-parallel", "null", "-monitor", "none", "-display", "none", "-vga", "none", "-daemonize", {:notify=>[:stdout, :stderr, :stdin]}]
Stderr: qemu-system-aarch64: -netdev user,id=net0,hostfwd=tcp::50022-:22,net=192.168.51.0/24,dhcpstart=192.168.51.3: DHCP must be different from host and DNS
see #40 for future develop of private network
@ppggff Is there is way to have two network card's configured on the vm.
Whenever I try to add a network via vagrant file, it overrides the eth0 and configures the 192.168.x.x range.
nodes = [
{
:hostname => 'root',
:net => '192.168.51.0/24',
:dhcp => '192.168.51.10',
:mem => '2G',
:cpus => '2'
},
]
Vagrant.configure(2) do |config|
nodes.each do |node|
config.vm.define node[:hostname] do |nodeconfig|
nodeconfig.vm.box_check_update = false
# nodeconfig.vm.synced_folder '.', '/vagrant', disabled: true
nodeconfig.vm.synced_folder ".", "/vagrant", type: "smb", smb_host: '192.168.34.10', smb_username: "xxx@xxx", smb_password: "xxxx"
nodeconfig.vm.box = 'ppggff/centos-7-aarch64-2009-4K'
nodeconfig.vm.hostname = node[:hostname] + ".example.com"
# nodeconfig.vm.provision :shell, :path => "bootstrap.sh"
nodeconfig.vm.provider :qemu do |qe|
qe.memory = node[:mem]
qe.smp = "cores=#{node[:cpus]}"
qe.qe.net_device = "virtio-net-device,netdev=net1"
qe.extra_netdev_args = "id=net1,net=#{node[:net]},dhcpstart=#{node[:dhcp]}"
end
end
end
end
Also, if you notice the SMB configuration also doesn't work and results in the permission denied
error [1].
I think the thread is here for this conversation - https://github.com/ppggff/vagrant-qemu/issues/40
@smitjainsj yes, you can:
extra_qemu_args
to add new configs for the second network cardnet_device
to nil
to disable the default first network card (if you want)Some notes about network in qemu:
For the vmnet config #40, I will try to give a workable vagrant config with extra_qemu_args
soon.
About the SMB error, please try the vagrant doc https://developer.hashicorp.com/vagrant/docs/synced-folders/smb
Hi all I am having the same issue as #33 but the solution offered isn't working for me. this is my vagrantfile: but the vms get the ip 127.0.0.1 when booting, 10.0.2.15 when typing ifconfig. I had to change the ssh port. Can anyone please assist?