mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Add :libvirt_host_ip and :libvirt_dhcp_start/stop
This allows networks with gateways on addresses other than .1 (.254 is a popular choice). Resolves #357.
This commit is contained in:
parent
3e79a37ad2
commit
ae37f17de8
@ -240,8 +240,14 @@ 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__host_ip` - Adress 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
|
||||
when creating new network. Default is true.
|
||||
* `:libvirt__dhcp_start` - First address given out via DHCP.
|
||||
Default is third address in range (after network name and gateway).
|
||||
* `:libvirt__dhcp_stop` - Last address given out via DHCP.
|
||||
Default is last possible address in range (before broadcast address).
|
||||
* `:libvirt__dhcp_bootp_file` - The file to be used for the boot image.
|
||||
Used only when dhcp is enabled.
|
||||
* `:libvirt__dhcp_bootp_server` - The server that runs the DHCP server.
|
||||
|
@ -121,7 +121,12 @@ module VagrantPlugins
|
||||
# Set IP address of network (actually bridge). It will be used as
|
||||
# gateway address for machines connected to this network.
|
||||
net = IPAddr.new(net_address)
|
||||
@interface_network[:ip_address] = net.to_range.begin.succ
|
||||
if @options[:host_ip].nil?
|
||||
# Default to first address (after network name)
|
||||
@interface_network[:ip_address] = net.to_range.begin.succ
|
||||
else
|
||||
@interface_network[:ip_address] = IPAddr.new @options[:host_ip]
|
||||
end
|
||||
|
||||
# Is there an available network matching to configured ip
|
||||
# address?
|
||||
@ -235,14 +240,13 @@ module VagrantPlugins
|
||||
network_address << "#{@interface_network[:netmask]}"
|
||||
net = IPAddr.new(network_address)
|
||||
|
||||
# First is address of network, second is gateway.
|
||||
# Start the range two
|
||||
# addresses after network address.
|
||||
# First is address of network, second is gateway (by default).
|
||||
# So start the range two addresses after network address by default.
|
||||
# TODO: Detect if this IP is not set on the interface.
|
||||
start_address = net.to_range.begin.succ.succ
|
||||
start_address = @options[:dhcp_start] || net.to_range.begin.succ
|
||||
|
||||
# Stop address must not be broadcast.
|
||||
stop_address = net.to_range.end & IPAddr.new('255.255.255.254')
|
||||
# Default to last possible address. (Stop address must not be broadcast address.)
|
||||
stop_address = @options[:dhcp_stop] || (net.to_range.end & IPAddr.new('255.255.255.254'))
|
||||
|
||||
@network_dhcp_enabled = true
|
||||
@network_dhcp_bootp_file = @options[:dhcp_bootp_file]
|
||||
|
Loading…
Reference in New Issue
Block a user