Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Static IP for Management Network in Vagrant libvirt provider

With below code, I can set the custom management network for guests, it works and sets vagrant management network ip addresses for the machines in defined network from DHCP pool. But I need to set specific ip adress for a specific machine, not from DHCP pool. Is there a way to set a static ip?

config.vm.provider "libvirt" do |v|
    v.management_network_name = "my_network"
    v.management_network_address = "10.11.12.0/24"
end
like image 701
edib Avatar asked Nov 25 '25 22:11

edib


1 Answers

I have found a non-proper way by a host command which runs virsh. But it worked.

system("virsh net-update my-network add ip-dhcp-host \"<host mac='52:54:00:fb:95:91' ip='10.11.12.13' />\" --live --config")

config.vm.provider "libvirt" do |v|
    v.management_network_name = "my_network"
    v.management_network_address = "10.11.12.0/24"
    v.management_network_mac = "52:54:00:fb:95:91"
end

like image 70
edib Avatar answered Nov 28 '25 17:11

edib