Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Lets say that I connect a device with a static IP in a switch. How does the switch know that there is new device connected? Does the device send an ICMP packet in order to tell that it is new on the switch/router? Is there any protocol to resolve this issue?

share|improve this question
Let's start here: Are you actually having an issue? – mfinni Feb 14 '11 at 15:09
Yes I have. I am fixing custom written TCP-IP drivers. – ralu Feb 18 '11 at 9:43
up vote 10 down vote accepted

Device may use ARP announcements,

ARP announcements

ARP may also be used as a simple announcement protocol. This is useful for updating other hosts' mapping of a hardware address when the sender's IP address or MAC address has changed. Such an announcement, also called a gratuitous ARP message, is usually broadcast as an ARP request containing the sender's protocol address (SPA) in the target field (TPA=SPA), with the target hardware address (THA) set to zero. An alternative is to broadcast an ARP reply with the sender's hardware and protocol addresses (SHA and SPA) duplicated in the target fields (TPA=SPA, THA=SHA).

share|improve this answer

The switch learns which MAC addresses are connected to which ports in one of two ways:

  1. The switch sees traffic from a port from a MAC address not in it's MAC address table and records that MAC address/port combination in it's MAC address table.

  2. Traffic destined for a MAC address that the switch does not have in it's MAC address table is flooded to all switch ports and the switch records on which port the device with the destination MAC address responds and records that MAC address/port combination in it's MAC address table.

As the entries in the dynamic MAC address table will time out (default aging time of 300 seconds on Cisco switches) the process of building/rebuilding the dynamic MAC address table is a regularly occurring event. In addition, if the switches are configured for STP (Spanning Tree Protocol), a topology change (plugging a new device in to the switch on a port not configured for port-fast) will reduce the MAC address aging time to 15 seconds (again, in Cisco switches) and this can cause unneccessary switch flooding. That's why all ports to which hosts are connected should be configured for port-fast, so that switch flooding due to a topology change is not caused by plugging a new host in to a switch port.

share|improve this answer
+1 for port-fast config; been burnt by that before. – gravyface Feb 14 '11 at 14:47
+1 - A correct answer amongst a sea of wrong ones. – Jason Berg Feb 14 '11 at 14:47

I believe switches use the ARP protocol.

Also check NDP

Hope this helps.

share|improve this answer

The switch first figures out that electrical connectivity has been established---at this point it knows something is plugged into the port.

Then (unless configured not to) the switch attempts to run autoneg to figure how how fast the link should run.

The source mac address of any traffic coming into the switch from the device will also get recorded in the switch's mac address table (which, is the list of what MAC addresses are out what ports).

When the router (IP layer) receives a packet for the IP the host owns,, the router will send out an ARP query on any interfaces on the relevant subnet to find the right MAC address for that IP. The ARP query hits the switch, which then floods out on all ports (on the relevant VLAN). Replies (which are transmitted by the device and thus recorded in the switch's MAC table), are transmitted back to the router, which records in it's MAC address table that the MAC for the given IP is out the port connected to the switch.

share|improve this answer
Good except that the recoeded MAC address is NOT sent to the router. The switch reports it'w own AMC on the port the router is connected to. ARP / MAC addressesa re only valid per ethernet segment, and a switch has a different segment on every port. – TomTom Feb 14 '11 at 12:30
I double-checked on a router-on-a-stick setup with a 2821 and a 2960 before answering. The arp table on the router includes the end device's mac address in the dotinterface, which means the arp requests are making it through the switch. – James Cape Feb 14 '11 at 13:57
@TomTom: That's not the case. The router will only discover the MAC address of the switch itself if: The switch is configured with an ip address, which it doesn't have to be, and if there is inbound traffic transiting the router destined for the ip address of the switch itself. The router works like any other network device in that it will ARP broadcast for the MAC address of any ip address it needs to forward traffic to. If you look at your router's MAC address table you should see entries for any devices connected to the switch that the router has forwarded traffic to. – joeqwerty Feb 14 '11 at 14:12

Your Answer


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.