diff --git a/lib/vagrant-lxc/action/private_networks.rb b/lib/vagrant-lxc/action/private_networks.rb index f96f76d..e6f3bda 100644 --- a/lib/vagrant-lxc/action/private_networks.rb +++ b/lib/vagrant-lxc/action/private_networks.rb @@ -22,16 +22,17 @@ module Vagrant end def configure_private_networks(env) - env[:machine].config.vm.networks.find do |type, config| + env[:machine].config.vm.networks.find_all.each do |type, config| next if type.to_sym != :private_network - container_name = env[:machine].provider.driver.container_name - address_type = config[:type] - ip = config[:ip] - bridge_ip = config.fetch(:lxc__bridge_ip) { build_bridge_ip(ip) } - bridge = config.fetch(:lxc__bridge_name) + container_name = env[:machine].provider.driver.container_name + container_interface = config[:interface] + address_type = config[:type] + ip = config[:ip] + bridge_ip = config.fetch(:lxc__bridge_ip) { build_bridge_ip(ip) } + bridge = config.fetch(:lxc__bridge_name) - env[:machine].provider.driver.configure_private_network(bridge, bridge_ip, container_name, address_type, ip) + env[:machine].provider.driver.configure_private_network(bridge, bridge_ip, container_name, container_interface, address_type, ip) end end diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index bafed55..ddaf4e3 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -130,8 +130,11 @@ module Vagrant @cli.info(*command) end - def configure_private_network(bridge_name, bridge_ip, container_name, address_type, ip) - @logger.info "Configuring network interface for #{container_name} using #{ip} and bridge #{bridge_name}" + def configure_private_network(bridge_name, bridge_ip, container_name, container_interface, address_type, ip) + if ! container_interface + container_interface = "eth1" + end + @logger.info "Configuring network interface #{container_interface} for #{container_name} using #{ip} and bridge #{bridge_name}" if ip ip += '/24' end @@ -170,6 +173,8 @@ module Vagrant cmd = [ Vagrant::LXC.source_root.join('scripts/pipework').to_s, bridge_name, + "-i", + container_interface, container_name, ip ||= "dhcp" ]