I have a dictionary with an IP address as the key and mac address as the value. One entry might look like this:
ip_dict['192.168.1.100'] = '33:22:11'
This dictionary is populated by reading the output of an arp table. What I am looking for is an ip address (the key) which has more than one mac address (the value). For each time I discover an ip with multiple values, I want to output an error showing the ip address and the list of mac addresses found.
Is there a simple way to do this?
Thanks for help.
--------------------------- Clarification ------------------------------------------
Sorry, it was late last night and wasn't thinking correctly.....
What I have is a mac dictionary with an ip address. There are no duplicate mac address. Each mac has a single ip address (value field). The question is which mac addresses have the same ip address?
Example:
mac_dict['11:22:33'] = '192.168.1.100'
mac_dict['11:23:44'] = '192.168.1.101'
mac_dict['11:23:43'] = '192.168.1.102'
mac_dict['12:43:55'] = '192.168.1.101'
mac_dict['54:22:65'] = '192.168.1.102'
mac_dict['21:1A:01'] = '192.168.1.101'
I'd like a way to generate a duplicate lists...
[('11':23:44', '12:43:55', '21:1A:01'), ('11:23:43', '54:22:65')]
The first three mac addresses all have 192.168.1.101 as their ip address, and the last two have 192.168.1.102 as their ip address. Because '11:22:33' is not duplicated, it doesn't appear in the list at all.
Thanks