To avoid mess my host pc, I have created a f39 vm in Gnome Boxes, that will be my host.
➜ rocky9 pwd
/home/chrisvm/projects/rocky9
# I was trying to create a custom network for regular user.
➜ rocky9 ll
total 8.0K
-rw-r--r--. 1 chrisvm chrisvm 246 Mar 1 21:26 custom-network.xml
-rw-r--r--. 1 chrisvm chrisvm 3.0K Mar 1 18:16 Vagrantfile
➜ rocky9
I have installed vagrant following this tutorial
I have installed virt-manager too.
With respect a installing plugins, there is two ways. By the way, what way do you recommend?
- from the fedora repo
- with the vagrant plugin install tool
The default vagrant-libvirt
from fedora repo was installed automatically.
➜ rocky9 dnf list vagrant-libvirt
Last metadata expiration check: 4:12:49 ago on Fri 01 Mar 2024 06:03:18 PM -05.
Installed Packages
vagrant-libvirt.noarch 0.11.2-2.fc39 @fedora
➜ rocky9
vagrant plugin list
vagrant-libvirt (0.12.2, global)
The network interfaces
➜ rocky9 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
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:47:44:9b brd ff:ff:ff:ff:ff:ff
inet 10.0.2.16/24 brd 10.0.2.255 scope global noprefixroute enp1s0
valid_lft forever preferred_lft forever
inet6 fec0::3f52:a148:3a05:2e87/64 scope site dynamic noprefixroute
valid_lft 86229sec preferred_lft 14229sec
inet6 fe80::26f7:c015:a854:df49/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:a6:45:51 brd ff:ff:ff:ff:ff:ff
inet 192.168.124.1/24 brd 192.168.124.255 scope global virbr0
valid_lft forever preferred_lft forever
➜ rocky9
# regular user mode
➜ rocky9 virsh net-list --all
Name State Autostart Persistent
----------------------------------------
➜ rocky9
# superuser mode
➜ rocky9 sudo !!
➜ rocky9 sudo virsh net-list --all
[sudo] password for chrisvm:
Name State Autostart Persistent
--------------------------------------------
default active yes yes
➜ rocky9
➜ rocky9 nmcli connection show -a
NAME UUID TYPE DEVICE
Wired connection 1 10ee4d8d-ef14-3349-82cb-23cad0e71d74 ethernet enp1s0
lo d8344f06-de67-4403-b9c1-7ce93fdcb413 loopback lo
virbr0 edb8af9d-ea6b-4a4c-8c43-ff9aa8928f61 bridge virbr0
➜ rocky9
About the problem or problems:
There is no problems creating rocky linux 9 vm with the default Vagrantfile. I means with the following commands.
# in the rocky9 folder
vagrant init
vagrant up
# login to the rocky server
vagrant ssh
The problems is that the default synced folder in the vm isn’t being created, There is no /vagrant
folder in the vm.
The another problems is that can’t to setup a private (static) ip.
If edit the Vagrantfile
like this.
Vagrant.configure("2") do |config|
config.vm.box = "generic/rocky9"
config.vm.network "private_network", ip: "192.168.124.10"
end
This is the error.
==> default: Creating shared folders metadata...
==> default: Starting domain.
==> default: Removing domain...
==> default: Deleting the machine folder
/usr/share/gems/gems/fog-libvirt-0.9.0/lib/fog/libvirt/requests/compute/vm_action.rb:7:in `create': Call to virDomainCreateWithFlags failed: Network not found: no network with matching name 'default' (Libvirt::Error)
from /usr/share/gems/gems/fog-libvirt-0.9.0/lib/fog/libvirt/requests/compute/vm_action.rb:7:in `vm_action'
from /usr/share/gems/gems/fog-libvirt-0.9.0/lib/fog/libvirt/models/compute/server.rb:76:in `start'
from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.11.2/lib/vagrant-libvirt/action/start_domain.rb:546:in `call'
from /usr/share/vagrant/gems/gems/vagrant-2.3.4/lib/vagrant/action/warden.rb:48:in `call'
from /usr/share/vagrant/gems/gems/vagrant-libvirt-0.11.2/lib/vagrant-libvirt/action/set_boot_order.rb:22:in `call'
Think that have to create a new network for the regular user mode. That’s why a have this file custom-network.xml
.
➜ rocky9 ll
total 8.0K
-rw-r--r--. 1 chrisvm chrisvm 246 Mar 1 21:26 custom-network.xml
-rw-r--r--. 1 chrisvm chrisvm 134 Mar 1 21:57 Vagrantfile
➜ rocky9
➜ rocky9 vim custom-network.xml
<network>
<name>custom-net</name>
<bridge name="custom-br"/>
<forward mode="nat"/>
<ip address="192.168.200.1" netmask="255.255.255.0">
<dhcp>
<range start="192.168.200.2" end="192.168.200.254"/>
</dhcp>
</ip>
</network>
With the help of chatGPT that’s have understood, but I am not sure. Can you help me how create the new network and how edit the Vagrantfile in the way it use the new network for regular user. Because vagrant is executed as regular user vagrant up
.