Skip to content

Instantly share code, notes, and snippets.

@bithive
Created June 3, 2011 22:16
Show Gist options
  • Save bithive/1007272 to your computer and use it in GitHub Desktop.
Save bithive/1007272 to your computer and use it in GitHub Desktop.
ARP for eth0:*
#!/usr/bin/env ruby
# ARPs for all the IPs aliased to this machine.
data = %x[ifconfig -a].split /\n\n/
data.each do |block|
d = /(eth\d:\d+)\s+/.match(block)
a = /inet addr:(\d+\.\d+\.\d+\.\d+)/.match(block)
next if d.nil? or a.nil?
device = d[1]
address = a[1]
%x[arping -c 3 -I #{device} #{address}]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment