MAC addresses on switch

Hi Rene,

Does L2 switch have mac address?

Hello Rathinasabapthy,

An unmanaged switch typically doesn’t have any MAC addresses since it’s just a simple device that builds a MAC address table and forwards frames.

Managed switches do have MAC addresses since they send/receive frames themselves. Either for management protocols like telnet/SSH but also for different protocols. On a Cisco switch, you’ll see that each interface has a unique MAC address and the switch will have a couple of virtual MAC addresses.

Can you please explain how does a MAC flood attack works and how does a switch behave when it is
the victim? Also can you tell me how a router builds its routing table?

Look forward to your anticipated response.
Kingsley

Hi Kingsley,

A switch will look at the source MAC address of each Ethernet frame and stores the MAC address in its MAC address table with the corresponding interface:

How it works is that you send a LOT of bogus Ethernet frames with random source MAC addresses. The switch will try to store all MAC addresses in the MAC address table and when it’s full, (depending on the switch) it can’t store any new MAC addresses anymore. The switch will fall back to a “hub” like behavior where it just floods all traffic on all interfaces.

You can counter MAC flooding with:

Here’s an introduction to how routers work and the routing table:

The routing table can be filled with static routes or dynamic routing protocols.

Rene

HI Rene,
I have one question, if two host (Pc) are connected to a switch (L2) both hosts are in a different subnet like
Host 1- 192.168.1.1 255.255.255.0
Host-2 10.1.1.1 255.0.0.0
whether these two PCs are able to communicate with each other ?

As per my knowledge switch only care about MAC address it does not care about ip addresses
at all, so that means when switch learn both the mac addresses of host 1 and host 2 they will be able to communicate with each other.

but when i tried this in GNS3 host 1 is not able to ping to host 2.

could you please explain this , two host of different subnet connected to a switch are able to communicate or not if yes why if not why.

Hello Deepak,

It’s good that you think stuff like this through.

Think of what host1 does when it wants to send an IP packet to destination 10.1.1.1?

From host1’s perspective, 10.1.1.1 is outside of its own subnet so in that case, it wants to use its default gateway. When no default gateway is configured, the IP packet will be discarded.

If you want to make this work, you need interVLAN routing:

Rene

Hello Deepak,

A pure L2 switch has no idea what the content of an Ethernet frame is, all it does is “switch” Ethernet frames based on the destination MAC address…that’s it.

L2 switches do support VLANs, that’s a L2 feature. The switch doesn’t know (or care) that there could be an IP packet in an Ethernet frame.

What happens when you use VLANs is that the switch creates a logical separation for each VLAN. If you assign interface 1-4 to VLAN 10 and 5-8 to VLAN 20 then there is no way that interface 5 can communicate with interface 1.

When the switch receives a broadcast on interface 1 then it will only forward it to interface 2,3, and 4 because those are in the same VLAN.

In the output of the MAC address table, you can see that a switch stores the interface, MAC address and the VLAN number:

SW1#show mac address-table dynamic 
          Mac Address Table

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
  10    000c.2954.83e5    DYNAMIC     Po2
  10    000c.2960.c231    DYNAMIC     Po2
  10    000c.29dd.e2b8    DYNAMIC     Po2
  10    000c.29f4.ace9    DYNAMIC     Po2
  20    0015.6524.f524    DYNAMIC     Gi0/8
  20    0015.6524.f5da    DYNAMIC     Gi0/31
  20    0015.6537.8a9d    DYNAMIC     Gi0/10
  20    0021.5a12.2f9c    DYNAMIC     Gi0/5
  20    089e.0116.b071    DYNAMIC     Po1
  20    3860.77d0.c9a0    DYNAMIC     Gi0/12

I hope this helps!

Rene