Class: VagrantPlugins::Boot2docker::Cap::ConfigureNetworks
- Inherits:
-
Object
- Object
- VagrantPlugins::Boot2docker::Cap::ConfigureNetworks
- Defined in:
- lib/vagrant-boot2docker/cap/configure_networks.rb
Class Method Summary collapse
Class Method Details
.configure_networks(machine, networks) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/vagrant-boot2docker/cap/configure_networks.rb', line 7 def self.configure_networks(machine, networks) machine.communicate.tap do |comm| networks.each do |n| if n.key?("ip") ifc = "/sbin/ifconfig eth#{n[:interface]}" #iface = "eth#{n[:interface]}" broadcast = (IPAddr.new(n[:ip]) | (~ IPAddr.new(n[:netmask]))).to_s # First kill the udhcp client for this interface - does not work. Disable for now # As a workaround, adding something similar to /var/lib/boot2docker/bootlocal.sh should fix it... #comm.sudo("ps -ef |grep dhcp | grep #{iface} | grep -v grep | tr -s ' ' | cut -d' ' -f2| xargs kill") comm.sudo("#{ifc} down") comm.sudo("#{ifc} #{n[:ip]} netmask #{n[:netmask]} broadcast #{broadcast}") comm.sudo("#{ifc} up") end end end end |