View image here: -Oh, and yes there is much more to my script in terms of getting the MAC address, subnet and other input values, so I don't actually hard code the MAC.Thanks again for the input. No biggie, but just another little annoyance. so I'll have to switch them to upper case before doing the grep. I do an SNMP get to get my MAC address but when it passes it back to me the Hex letters are in lower case. I should have thought of this before - View image here: - Thanks.However, I do have one problem with the grep command. However, my testing environment is all behind the router and therefore all devices will have a subnet of 20 after switching to DHCP addressing.I used your fping -c 1 -g 192.168.20.0/24 & arp -n | grep "00:15:A FF:81:93" command. Basically that means with this method it won't show up. anything not on your local subnet will probable show up as your router's mac address or not show up. '% MACchild = pexpect.spawn ('fping -c 1 -g 192.168.20.0/24')i = child.expect_exact ()child = pexpect.spawn ('arp')i = 1while i != 0:-i = child.expect (, timeout=2)-i = child.expect_exact (, timeout=2)-if i=0:-DHCP_NID = child.before-i = child.expect_exact (, timeout=2)-if child.before = MAC:-print 'IP FOUND : DHCP_NID = %s'% DHCP_NID-break-else:-i = 1NOTE: there are blank spaces in the child.expect_exact calls as well but are weeded out by the format of the forum. MAC = '00:15:A FF:81:93'#print 'Searching for New DHCP IP address for MAC address %s. Just to share with the community - View image here: -Here's what I have in my script and it works.If anyone sees any major issues, please let me know.Thanks to all who helped me accomplish this task. because I just when back and called arp again and it's showing me only the compelted addressed. I'm getting there - View image here: -EDIT: there seems to be a timer after which the incomplete entries are removed from the table. does anyone know how to display the arp table with only the "completed" addresses? The man pages don't seem too much help, or maybe I missed it.Thanks for the help so far. After this I'm trying to parse backwards to temporarily save the IP address then move forward to check the MAC address against my target MAC address.It seems messy. Ok I've started using fpingex: fping -c 1 -g 192.168.20.0/24This goes through one iteration of all addresses in the '20' subnet.After this I do an arp, which gives me all the addresses, incomplete and complete, not in order.So, I'm trying to do a pexpect for "ether" which is the HWtype of the "completed" addresses. Could you name one that is included with most Linux distributions? or is generic enough to run on most and can be called from a script? After this I should have an arp table to parse through looking for my MAC address.Now to implement this and see if I can egt this to work from a script (BTW: the script is python using pexpect)quote:There are numerous tools that will do this for you. Pinging does populate the arp table, so if I ping sweep, I would be pinging every address, whether there is a device associated or not. like in Windows "arp -d"? I will need to do this (I assume) in order to no longer have the "old" IP associated to the MAC address (zombie entry) before parsing for the "new" IP?Broadcast pinging does not seem to send arp requests so does not populate the arp table.Frennzy, ok I think I got it, thanks. Incidentally, does anyone know if there is an arp parameter to delete the entire table in Linux. so the "new" IP is not in the arp table, but I do have the MAC address. there was recently traffic, so it is in my arp table, but then I change the IP to use DHCP instead of a static address. no, I'm referring to ping sweeping, not pinging a broadcast addres.that is, ping each address in your subnet, incrementally.There are numerous tools that will do this for you.įint, ya see there is where the problem lies. Could there be a terminal command to display this lease table in Linux from my router?I was thinking maybe using Dynamic DNS and that way I could simply just use the host name of my device whether it has a static IP or using DHCP? But to do this I believe I would need to setup a server system to act as the DHCP and DNS server?I appreciate your ideas. I can see the DHCP lease table through the web GUI to my router (and possibly some CLI commands to the router) but I would like to keep my scripts generic enough that they would work on other networks with different DHCP servers. Quote:Originally posted by Mako22:Hey Frennzy,When you say Ping sweep the subnet, are you referring to broadcast pinging? ie: ping -b 192.168.20.255 to find all the devices on subnet 20?Broadcast ping does not seem to use arp requests and therefore does not update the arp table.My DHCP server is running on my router.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |