7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# 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
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
|