Do switches look at MAC addresses?

Let's say we have a network like the one in the image below and the switches MAC tables are empty and the ARP tables are also empty. I want to send a packet from Host A to Host B. The question I want to ask is in what order and which MAC address the Switches learn?

Here is what i know till now:

Host 1 creates the packet with the Destination IP of Host B (172.30.2.16) and sends it.

Switch 1 gets the packet and looks up in his MAC Table (its empty) and then sends it to all of his ports (flood) and in meanwhile saves up the Source MAC of Host A in his MAC Table.

The packet comes to the Router which sends it to Switch 2. Now does the Switch 2 learns (saves) the Host A MAC address (caz its the source MAC) or it learns the Router MAC from which the packet came and its port is connected?

Now the Switch 2 floods all ports and gets positive answer from Host B and learns(saves) his MAC address in his table. Now the process is going in reverse to Host A.

Switch 1 MAC Table:

Port------Source MAC

1------Host A MAC

5------Router's MAC or is it Host B MAC ?

Switch 2 MAC Table:

Port------Source MAC

1------Host A MAC or Router's MAC ?

3------Host B

Do switches look at MAC addresses?

Thank you so much!

Do switches look at MAC addresses?

Zac67

73.8k2 gold badges58 silver badges124 bronze badges

asked Aug 22, 2017 at 11:29

2

Each router replaces the Original source MAC address with the MAC adddress of the interface where the packet is going out of the router.

(in this case, the packet comes in through the red interface 
 and goes out on the brown interface).

So switch 2 and Host B learn the MAC address of the brown interface of the router.

They are unaware of the original MAC adddress, and they don't need to know it. When Host B needs to reply to Host Ait simply sends the packet to Host A IP address and Router's brown interface MAC.

answered Aug 22, 2017 at 11:39

Do switches look at MAC addresses?

jcbermujcbermu

4,43715 silver badges20 bronze badges

3

A router removes the frame around an incoming IP packet and encapsulates the packet with a new frame (depending on the layer 2 protocol) when passing it on.

The MAC tables of the switches are populated by ARP:

  1. When Host A is about to send a packet to Host B it queries its local routing table.
  2. The routing table indicates that Router is required as gateway to forward the packet.
  3. Router is connected by Ethernet, so its MAC address needs to be learned.
  4. Host A sends a (broadcast) ARP request for Router's IP.
  5. This propagates Host A's MAC address to all switches in the broadcast domain.
  6. Router responds with its MAC address, propagating its MAC address to the switches on the required path (when response is unicast) or on all switches (when response is broadcast).
  7. Host A learns Router's MAC address from the response
  8. Host A encapsulates the IP packet in an Ethernet II frame addressed to Router's MAC and transmits it.
  9. Router pretty much uses the same mechanism to forward the packet inside a new Ethernet frame to Host B.

To be exact, each switch removes the (layer 1) Ethernet packet around each (layer 2) frame on receipt and puts a new Ethernet packet around it when forwarding. So, layer 3 uses layer 2 for transport which in turn uses layer 1 for transport. Layer 1 is where the bits actually get moved.

answered Aug 22, 2017 at 20:42

Do switches look at MAC addresses?

Zac67Zac67

73.8k2 gold badges58 silver badges124 bronze badges

Accessing MAC address views and searches

Syntax

show mac-address
[vlan ]
[ ]
[ mac-addr ]

Listing all learned MAC addresses on the switch, with the port number on which each MAC address was learned

HP Switch# show mac-address

Listing all learned MAC addresses on one or more ports, with their corresponding port numbers

For example, to list the learned MAC address on ports A1 through A4 and port A6:

HP Switch# show mac-address a1-a4,a6

Listing all learned MAC addresses on a VLAN, with their port numbers

This command lists the MAC addresses associated with the ports for a given VLAN. For example:

HP Switch# show mac-address vlan 100


Do switches look at MAC addresses?

NOTE: The switches operate with a multiple forwarding database architecture.


Finding the port on which the switch learned a specific MAC address

For example, to find the port on which the switch learns a MAC address of 080009-21ae84:

Do switches look at MAC addresses?

Accessing MAC address views and searches (Menu)

Viewing and searching per-VLAN MAC-addresses

This feature lets you determine which switch port on a selected VLAN is being used to communicate with a specific device on the network.

From the Main Menu, select:

  1. The switch then prompts you to select a VLAN.

    Do switches look at MAC addresses?

  2. Use the Space bar to select the VLAN you want, and then press [Enter].

    The switch then displays the MAC address table for that VLAN (Example of the address table.)

    Example of the address table

    Do switches look at MAC addresses?

    To page through the listing, use Next page and Prev page.

Finding the port connection for a specific device on a VLAN

This feature uses a device's MAC address that you enter to identify the port used by that device.

  1. Proceeding from Example of the address table, press [S] (for Search), to display the following prompt:

    Enter MAC address: _
    
  2. Enter the MAC address you want to locate and press [Enter].

    The address and port number are highlighted if found (Example of menu indicating located MAC address.) If the switch does not find the MAC address on the currently selected VLAN, it leaves the MAC address listing empty.

    Example of menu indicating located MAC address

    Do switches look at MAC addresses?

  3. Press [P] (for Prev page) to return to the full address table listing.

Viewing and searching port-level MAC addresses

This feature displays and searches for MAC addresses on the specified port instead of for all ports on the switch.

  1. From the Main Menu, select:

    Listing MAC addresses for a specific port

    Do switches look at MAC addresses?

  2. Use the Space bar to select the port you want to list or search for MAC addresses, then press [Enter] to list the MAC addresses detected on that port.

Determining whether a specific device is connected to the selected port

Proceeding from step 2, above:

  1. Press [S] (for Search), to display the following prompt:

    Enter MAC address: _
    
  2. Enter the MAC address you want to locate and press [Enter].

    The address is highlighted if found. If the switch does not find the address, it leaves the MAC address listing empty.

  3. Press [P] (for Prev page) to return to the previous per-port listing.

Do switches filter MAC addresses?

Although switches filter most frames based on MAC addresses, they do not filter broadcast frames. For other switches on the LAN to receive broadcast frames, switches must flood these frames out all ports. A collection of interconnected switches forms a single broadcast domain.

Do switches use IP addresses or MAC addresses?

Network switches refer to MAC addresses in order to send Internet traffic to the right devices, not IP addresses. Every device that connects to the Internet has an IP address.

How do switches find MAC addresses?

A switch can learn MAC address in two ways; statically or dynamically. In the static option, we have to add the MAC addresses in the CAM table manually. In the dynamic option, the switch learns and adds the MAC addresses in the CAM table automatically. The switch stores the CAM table in the RAM.

Do switches check IP addresses?

Remember: switch does not look into the IP packet and forwards frame as is based on the destination MAC address.