Multiple IP's with same MAC Address

Protecting your Linux box
Post Reply
sevensins
Havaldaar
Posts: 117
Joined: Tue Apr 13, 2004 1:45 pm
Location: PAKISTAN
Contact:

Multiple IP's with same MAC Address

Post by sevensins »

AOA,

on my network I have 4 subnets. People on one subnet add the other subnet free ip address to bypass the gateway (lynx box). e.g
# arp -aven | grep 00:16:76:94:49:BB
192.168.59.38 ether 00:16:76:94:49:BB C eth0
192.168.79.50 ether 00:16:76:94:49:BB C eth0


I was wondering is there any way to find out duplicate hosts (ip's) with same mac address?

Any help, guidance would be much appreciated.
Regards,

-----------------------------------------------------------------
A wise monkey never monkies w/ another monkey's monkey!
lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Re: Multiple IP's with same MAC Address

Post by lambda »

sevensins wrote:I was wondering is there any way to find out duplicate hosts (ip's) with same mac address?
sure. here's a little script to help you out:

Code: Select all

#!/usr/bin/env ruby

reg = Regexp.new /^([0-9.]+)\s+\w+\s+([0-9A-F:]+)/
macs = {}

f = IO.popen '/usr/sbin/arp -aven'
f.each_line do |line|
  matches = reg.match line
  if matches
    ip = matches[1]
    ether = matches[2]
    if macs[ether]
      macs[ether] << ip
    else
      macs[ether] = [ip]
    end
  end
end

macs.each { |mac, iplist| puts "#{mac} has more than one ip: #{iplist}" if iplist.size > 1 }

exit 0
sevensins
Havaldaar
Posts: 117
Joined: Tue Apr 13, 2004 1:45 pm
Location: PAKISTAN
Contact:

Post by sevensins »

thanx a lot, I will try it...
Regards,

-----------------------------------------------------------------
A wise monkey never monkies w/ another monkey's monkey!
raheelahmad
Naik
Posts: 87
Joined: Tue Mar 06, 2007 4:58 am
Location: Karachi
Contact:

Post by raheelahmad »

nice one
-
Raheel Ahmad
Post Reply