diff --git a/README.md b/README.md
index 4bca469..7501a0b 100644
--- a/README.md
+++ b/README.md
@@ -490,6 +490,13 @@ An examples of network interface definitions:
:libvirt__network_address => '10.20.30.0'
end
+ # Private network (as above) using a domain name
+ config.vm.define :test_vm1 do |test_vm1|
+ test_vm1.vm.network :private_network,
+ :ip => "10.20.30.40",
+ :libvirt__domain_name => "test.local"
+ end
+
# Private network. Point to Point between 2 Guest OS using a TCP tunnel
# Guest 1
config.vm.define :test_vm1 do |test_vm1|
@@ -561,6 +568,8 @@ starts with `libvirt__` string. Here is a list of those options:
* `: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__domain_name` - DNS domain of the DHCP server. Used only
+ when creating new network.
* `: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
diff --git a/lib/vagrant-libvirt/action/create_networks.rb b/lib/vagrant-libvirt/action/create_networks.rb
index 2aa1440..69cb0e2 100644
--- a/lib/vagrant-libvirt/action/create_networks.rb
+++ b/lib/vagrant-libvirt/action/create_networks.rb
@@ -56,6 +56,7 @@ module VagrantPlugins
netmask: @options[:netmask],
network_address: nil,
bridge_name: nil,
+ domain_name: nil,
ipv6_address: options[:ipv6_address] || nil,
ipv6_prefix: options[:ipv6_prefix] || nil,
created: false,
@@ -121,6 +122,7 @@ module VagrantPlugins
def handle_ip_option(env)
return unless @options[:ip]
net_address = nil
+
unless @options[:forward_mode] == 'veryisolated'
net_address = network_address(@options[:ip], @options[:netmask])
@@ -317,6 +319,8 @@ module VagrantPlugins
@network_dhcp_enabled = false
end
+ @network_domain_name = @options[:domain_name]
+
begin
@interface_network[:libvirt_network] = \
@libvirt_client.define_network_xml(to_xml('private_network'))
diff --git a/lib/vagrant-libvirt/templates/private_network.xml.erb b/lib/vagrant-libvirt/templates/private_network.xml.erb
index 48e82ee..71ed4ba 100644
--- a/lib/vagrant-libvirt/templates/private_network.xml.erb
+++ b/lib/vagrant-libvirt/templates/private_network.xml.erb
@@ -2,6 +2,10 @@
<%= @network_name %>
+ <% if @network_domain_name %>
+
+ <% end %>
+
<% if (@network_forward_mode != 'none' && @network_forward_mode != 'veryisolated') %>
<% if @network_forward_device %>
diff --git a/lib/vagrant-libvirt/util/network_util.rb b/lib/vagrant-libvirt/util/network_util.rb
index 33c0141..dde2b18 100644
--- a/lib/vagrant-libvirt/util/network_util.rb
+++ b/lib/vagrant-libvirt/util/network_util.rb
@@ -112,6 +112,9 @@ module VagrantPlugins
false
end
+ domain_name = xml.at_xpath('/network/domain/@name')
+ domain_name = domain_name.value if domain_name
+
# Calculate network address of network from ip address and
# netmask.
network_address = (network_address(ip, netmask) if ip && netmask)
@@ -123,6 +126,7 @@ module VagrantPlugins
network_address: network_address,
dhcp_enabled: dhcp_enabled,
bridge_name: libvirt_network.bridge_name,
+ domain_name: domain_name,
created: true,
active: libvirt_network.active?,
autostart: libvirt_network.autostart?,