Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Here is the real scenario. I have say 4 machines not having any IP address yet connected to a switch. In one of the machines (OS=CentOS), I would install a DHCP server and would provide the other machines IP addresses. Prior to assigning them IP addresses, I need to get the MAC address of each of the machines that I would assign IP addresses to.

So, my question here is how to I get the MAC addresses of all the machines connected to a switch when NO machine has got any IP address yet?

It's mandatory for my use case that I won't be having any IP addresses before the MAC addresses.

-Thanks

share|improve this question
    
What are you really trying to do? Whatever it is, there is might a better way of accomplishing the task than getting mac-addresses before DHCP. –  Mike Pennington Jun 28 '12 at 11:06
    
Yes, you are right. I think I should think of some some other way to accomplish my task. –  SSaikia_JtheRocker Jun 28 '12 at 11:39
    
What is the task you're trying to do? –  Mike Pennington Jun 28 '12 at 11:43
1  
I suppose "walk up to the machines and read the numbers off the sticker" would be far too Sysadmin 1.0? –  womble Jun 28 '12 at 14:44
    
Mike: I was given a task to find the MAC addresses and assign IP addresses to multiple machines using DHCP , where I can't have manual access. I think after they are going to use PXE booting, not sure :) –  SSaikia_JtheRocker Jun 30 '12 at 12:01

3 Answers 3

up vote 5 down vote accepted

Ethernet switches have no way to show you mac-addresses of end stations before the end-stations send traffic; ethernet switches know what mac-address is attached by looking at the source mac-address field of the PC's traffic.

If you use 802.1x authentication, you have a tiny window of time to get this information before they get an IP address from DHCP, but doing this reliably is impossible in the real world; everything happens too quickly.

If you need to know mac-addresses beforehand, then go to all PCs and conduct an inventory.

share|improve this answer
    
Cisco switches have a "show mac address-table" command which doesn't relate to ARP.. I think? –  pauska Jun 28 '12 at 11:09
    
@pauska, that is the switch's CAM table. It is precisely the table I was talking about when I said the switch only knows the source mac-address after traffic is sent the first time. –  Mike Pennington Jun 28 '12 at 11:10
    
Sorry can't upvote guys. No reputation yet. –  SSaikia_JtheRocker Jun 28 '12 at 11:40
    
I slightly disagree with this. When a PC connects, it will send a DHCP request. Even if a DHCP answer is never returned, the MAC address will then be registered into the switch's arp/mac address table. –  jftuga Jun 28 '12 at 15:53
    
@jftuga, if the PC has no IP address, then it should have no ARP entry. I am not sure if you're seriously suggesting this as a solution or merely pointing out a corner-case we'd both agree on. –  Mike Pennington Jun 28 '12 at 16:00

If the machines never talked to the network, this isn't possible but if they communicated with the switch at least once and the switch is SNMP-capable, you could try to query the ARP table of the switch.

But with just four machines, just walk to them and write the MAC down.

share|improve this answer
    
Sorry can't upvote. No reputation yet. –  SSaikia_JtheRocker Jun 28 '12 at 11:40

Mmmhhh...

Weird scenario... Can't think of any situation in which this would make sense...

But anyway:
Setup the DHCP server to only supply reserved addresses (on MAC basis) and WITHOUT any dynamic DHCP pool.

That way the clients can request DHCP addresses all day long but won't get any until you add them to the reserved addresses.
But because the clients are attempting to get DHCP their mac-addresses will be learned and stored in the CAM table of the switch.

You can't get them from the server itself as far as I know. Normally mac-addresses can be seen in the ARP cache (arp -a command on most operating systems), but that is only AFTER there is an IP address linked to the MAC-address.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.