diff --git a/plugins/guests/gentoo/cap/configure_networks.rb b/plugins/guests/gentoo/cap/configure_networks.rb index ab27a58e3..38b18501f 100644 --- a/plugins/guests/gentoo/cap/configure_networks.rb +++ b/plugins/guests/gentoo/cap/configure_networks.rb @@ -12,15 +12,11 @@ module VagrantPlugins comm = machine.communicate commands = [] - interfaces = [] + interfaces = machine.guest.capability(:network_interfaces, "/bin/ip") # Remove any previous network additions to the configuration file. commands << "sed -i'' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net" - comm.sudo("ifconfig -a | grep -o ^[0-9a-z]* | grep -v '^lo'") do |_, stdout| - interfaces = stdout.split("\n") - end - networks.each_with_index do |network, i| network[:device] = interfaces[network[:interface]] diff --git a/plugins/guests/linux/cap/network_interfaces.rb b/plugins/guests/linux/cap/network_interfaces.rb index fd1480aa6..3360fde78 100644 --- a/plugins/guests/linux/cap/network_interfaces.rb +++ b/plugins/guests/linux/cap/network_interfaces.rb @@ -7,9 +7,9 @@ module VagrantPlugins # eth0\nenp0s8\nenp0s9 # # @return [Array] - def self.network_interfaces(machine) + def self.network_interfaces(machine, path = "/sbin/ip") s = "" - machine.communicate.sudo("/sbin/ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'") do |type, data| + machine.communicate.sudo("#{path} -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'") do |type, data| s << data if type == :stdout end s.split("\n")