Skip to content

Instantly share code, notes, and snippets.

@eznix86
Created November 29, 2023 13:08
Show Gist options
  • Save eznix86/1cafdf2bf091612a64f6e042ab514f24 to your computer and use it in GitHub Desktop.
Save eznix86/1cafdf2bf091612a64f6e042ab514f24 to your computer and use it in GitHub Desktop.
Vagrant VMs with different subnet
Vagrant.configure("2") do |config|
vms_in_network1 = 2
vms_in_network2 = 3
(1..vms_in_network1).each do |i|
config.vm.define "vm#{i}" do |vm|
vm.vm.box = "ubuntu/noble64"
vm.vm.network "private_network", ip: "192.168.33.#{i + 9}" # 192.168.33.xxx
end
end
(1..vms_in_network2).each do |i|
config.vm.define "vm#{i + vms_in_network1}" do |vm|
vm.vm.box = "ubuntu/noble64"
vm.vm.network "private_network", ip: "192.168.34.#{i + 9}" # 192.168.34.xxx
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment