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.

If we have two host with same ip on the same switch and a packet comes for that IP, then how will the switch know where to send the packet. Will it send to both hosts or only one of them, if one then why?

share|improve this question

migrated from stackoverflow.com Jun 3 '11 at 19:48

This question came from our site for professional and enthusiast programmers.

add comment

3 Answers

bdonian's answer is correct about MAC addressing, however the real-world answer is

"Unless you're doing some form of link aggregation it is an incorrect network configuration - fix it."

Multiple hosts with the same IP on the same network without proper switch configuration are an incorrect network configuration and the results are inconsistent. Many things factor into "what will happen". Generally, expect problems from inconsistent behaviour to the point of no traffic.

If you want multiple hosts sharing a single IP for fail-over or load balancing that is known by many names; bonding, trunking, link-aggregation, etc., and usually needs a switch that supports one or more of these methods. http://en.wikipedia.org/wiki/Link_aggregation

share|improve this answer
add comment

Network switches don't examine the IP of the packet; they examine the destination MAC address. Things would go something like this:

  1. Sending host A wants to send a packet to IP X.
  2. Host A sends a broadcast ARP request for IP X.
  3. Switch takes note of Host A's MAC address and switch port.
  4. Both Hosts B and C respond to the broadcast ARP request with a unicast ARP reply containing their MAC address.
  5. Switch takes note of Host B and C's (distinct) MAC addresses and switch ports (but not their IPs!)
  6. One of the two replies arrives first - assume host B.
  7. Host A makes a note that IP X = Host B's MAC.
  8. Host A sends a packet to Host B's MAC and IP X
  9. The ARP reply from Host C arrives. Host A may or may not overwrite the entry for IP X.
  10. The switch matches Host B's MAC address and forwards the packet to Host B's port.
  11. Host B receives the packet.
share|improve this answer
add comment

In Unix/Linux land, one host will detect the other host with the same address and simply refuse to stay on the net.

But as someone previously pointed out: if you do this, your network is broken.

share|improve this answer
add comment

Your Answer

 
discard

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