Specify a MAC address for public_network interface

This commit is contained in:
Jevgeni Kiski 2013-09-16 23:26:39 +03:00
parent 75739849ad
commit 1e2f49f028
3 changed files with 7 additions and 3 deletions

View File

@ -103,7 +103,7 @@ This provider exposes quite a few provider-specific configuration options:
* `memory` - Amount of memory in MBytes. Defaults to 512 if not set.
* `cpus` - Number of virtual cpus. Defaults to 1 if not set.
* `nested` - [Enable nested virtualization](https://github.com/torvalds/linux/blob/master/Documentation/virtual/kvm/nested-vmx.txt). Default is false.
* `volume_cache` - cache attribute controls the cache mechanism, possible values are "default", "none", "writethrough", "writeback", "directsync" and "unsafe". [See driver->cache in libvirt documentation](http://libvirt.org/formatdomain.html#elementsDisks).
* `volume_cache` - Controls the cache mechanism. Possible values are "default", "none", "writethrough", "writeback", "directsync" and "unsafe". [See driver->cache in libvirt documentation](http://libvirt.org/formatdomain.html#elementsDisks).
Specific domain settings can be set for each domain separately in multi-VM
environment. Example below shows a part of Vagrantfile, where specific options
@ -172,7 +172,7 @@ An examples of network interface definitions:
# Public Network
config.vm.define :test_vm1 do |test_vm1|
test_vm1.vm.network :public_network, :dev => "eth0", :mode => 'bridge'
test_vm1.vm.network :public_network, :dev => "eth0", :mode => 'bridge', :mac => '92-c6-8f-94-b5-8d'
end
```
@ -191,7 +191,7 @@ The second interface is created and bridged into the physical device 'eth0'.
This mechanism uses the macvtap Kernel driver and therefore does not require
an existing bridge device. This configuration assumes that DHCP and DNS services
are being provided by the public network. This public interface should be reachable
by anyone with access to the public network.
by anyone with access to the public network. If `:mac` is not defined it will be generated.
### Private Network Options

View File

@ -72,6 +72,7 @@ module VagrantPlugins
template_name = 'public_interface'
@device = iface_configuration.fetch(:dev, 'eth0')
@mode = iface_configuration.fetch(:mode, 'bridge')
@mac = iface_configuration.fetch(:mac, false)
@logger.info("Setting up public interface using device #{@device} in mode #{@mode}")
end

View File

@ -1,5 +1,8 @@
<interface type='network'>
<source network='<%= @network_name %>'/>
<% if @mac %>
<mac address='<%= @mac %>'/>
<% end %>
<target dev='vnet<%= @iface_number %>'/>
<alias name='net<%= @iface_number %>'/>
<model type='virtio'/>