Add option to configure the network address when using DHCP

This commit is contained in:
Hugo Stijns
2017-11-23 09:27:41 +01:00
parent 9bff74d77e
commit b00816680a
2 changed files with 13 additions and 3 deletions

View File

@@ -488,6 +488,13 @@ An examples of network interface definitions:
test_vm1.vm.network :private_network, :ip => "10.20.30.40"
end
# Private network using DHCP and a custom network
config.vm.define :test_vm1 do |test_vm1|
test_vm1.vm.network :private_network,
:type => "dhcp",
:libvirt__network_address => '10.20.30.0'
end
# Private network. Point to Point between 2 Guest OS using a TCP tunnel
# Guest 1
config.vm.define :test_vm1 do |test_vm1|
@@ -556,6 +563,7 @@ starts with `libvirt__` string. Here is a list of those options:
network 'default' is used.
* `:libvirt__netmask` - Used only together with `:ip` option. Default is
'255.255.255.0'.
* `:libvirt__network_address` - Used only when `:type` is set to `dhcp`. Only `/24` subnet is supported. Default is `172.28.128.0`.
* `:libvirt__host_ip` - Address to use for the host (not guest). Default is
first possible address (after network address).
* `:libvirt__dhcp_enabled` - If DHCP will offer addresses, or not. Used only

View File

@@ -240,8 +240,10 @@ module VagrantPlugins
end
def handle_dhcp_private_network(env)
net_address = '172.28.128.0'
net_address = @options[:libvirt__network_address]
net_address = '172.28.128.0' unless net_address
network = lookup_network_by_ip(net_address)
@interface_network = network if network
# Do we need to create new network?