diff options
author | Mark J. Titorenko <nospam-github.com@titorenko.net> | 2014-11-18 19:31:48 +0000 |
---|---|---|
committer | Mark J. Titorenko <nospam-github.com@titorenko.net> | 2014-11-18 19:31:48 +0000 |
commit | 283e57d8c66e9d567a146b9d39aef45361d0ba1a (patch) | |
tree | bd3b3e49523cccae943db85fba2022e1f7cd204c | |
parent | b13c4c6a458f4326dd73de380432fbc5e9ce3a77 (diff) | |
parent | 349cb7f56e65e8f986d5c807c0f07cf15b149e88 (diff) | |
download | net-dhcp-ruby-283e57d8c66e9d567a146b9d39aef45361d0ba1a.tar.gz |
Merge pull request #11 from rightscale/dhcp-discover-bsd-and-centos7
Dhcp discover bsd and centos7
-rw-r--r-- | lib/net/dhcp/core.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/net/dhcp/core.rb b/lib/net/dhcp/core.rb index 95ee7d4..fc27a86 100644 --- a/lib/net/dhcp/core.rb +++ b/lib/net/dhcp/core.rb @@ -153,7 +153,11 @@ module DHCP mac = mac_line.strip.split(":")[1].gsub("-","").strip end else - mac = `/sbin/ifconfig | grep HWaddr | cut -c39- | head -1`.chomp.strip.gsub(/:/,'') + ifcfg_out = `/sbin/ifconfig`.chomp + matches1 = ifcfg_out.scan(/HWaddr ([a-h0-9:]+)/i).flatten # Linux + matches2 = ifcfg_out.scan(/ether ([a-h0-9:]+)/i).flatten # Some Linux (EL7), BSDs + mac = matches1.first || matches2.first + mac = mac.gsub(/:/,"") if mac end mac = '000000000000' if mac.empty? self.chaddr = [mac].pack('H*').unpack('CCCCCC') |