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

Need assistance getting vagrant to use existing bridge intf while also assigning them static IPs #1339

Closed
cheepsoot opened this issue Sep 7, 2021 · 2 comments
Labels

Comments

@cheepsoot
Copy link

cheepsoot commented Sep 7, 2021

Hello everyone!

Could someone kindly help me to understand why I cannot get vagrant VMs to work with an existing "br1" interface and to also assign them static private IPs?

My error is as follows:
Error while activating network: Call to virNetworkCreate failed: internal error: Network is already in use by interface br1.

I already have KVM running on a server which has 4 VMS running on a 192.168.1.x network. I am wanting to spin up new vagrant VMs that will also have a interface assigned on that same 192.168.1.x net. I cannot find how to assign IPs statically via Vagrant and when I try the following config line in the Vagrantfile, I am then given that error I pasted above.

These are all different config lines I've used with no success:

#web02.vm.network :public_network, :dev => "br1", :type => "bridge"

#web02.vm.network :private_network, :ip => "192.168.3.116", :libvirt__netmask => '255.255.255.0', :libvirt__forward_mode => "route"

^ This line actually worked but it created a new interface with that "192.168.3.116" ip on the host and was then linked to my guest vm by the virbr interface. I would have to setup routing the get the two networks to talk to each other and I would like to avoid this if possible"

#web02.vm.network :private_network, :libvirt__ip => "192.168.1.116", :libvirt__netmask => "255.255.255.0", :libvirt__forward_mode => "nat"

#web02.vm.network :private_network, :ip => "192.168.121.116", :libvirt__netmask => '255.255.255.0', :libvirt__network_name => "vagrant-libvirt"

Any suggestions to get my desired outcome of getting new VMs spun up which use the 192.168.1.x network??

@electrofelix
Copy link
Contributor

@cheepsoot can you provide the network xml for the network that you want to add the additional VMs from vagrant to it?

virsh net-dumpxml <network-name>

you should be able to get the network name from virsh net-list --all.

I suspect it's just a case of matching up either the IPs in a way that vagrant-libvirt spots that they are part of that network, or to use the network name to help it find the correct one to use.

It sounds like you want to assign them static IPs on the existing br1 network? Since you don't want to have to hook up the separate networks.

So I'm wondering why the following by itself isn't sufficient?:

web02.vm.network :public_network, :dev => "br1", :type => "bridge", :ip => "192.168.1.<x>"

If it's not, it might just need :libvirt__network_name with the correct name from above to know which one to use, but otherwise really depends on how the existing network that you want to connect to is constructed, so easier if you can share the XML from that.

@no-response
Copy link

no-response bot commented Dec 9, 2021

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@no-response no-response bot closed this as completed Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants