# MAC addresses on switch

**URL:** <https://forum.networklessons.com/t/mac-addresses-on-switch/3421>\
**Category:** Switching\
**Created:** [March 27, 2018, 6:56am UTC](https://forum.networklessons.com/t/mac-addresses-on-switch/3421 "2018-03-27T06:56:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![saba.t240](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/s/b3f665/32.png) [@saba.t240](https://forum.networklessons.com/u/saba.t240)\
**Post date:** [March 27, 2018, 6:56am UTC](https://forum.networklessons.com/t/mac-addresses-on-switch/3421/1 "2018-03-27T06:56:54Z")

</div>

Hi Rene,

Does L2 switch have mac address?

---

<div class="post-metadata">

**Author:** ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)\
**Post date:** [April 3, 2018, 1:07pm UTC](https://forum.networklessons.com/t/mac-addresses-on-switch/3421/2 "2018-04-03T13:07:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![yahkenergy](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/y/df705f/32.png) [@yahkenergy](https://forum.networklessons.com/u/yahkenergy)\
**Post date:** [April 11, 2018, 5:17pm UTC](https://forum.networklessons.com/t/mac-addresses-on-switch/3421/3 "2018-04-11T17:17:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)\
**Post date:** [April 13, 2018, 8:45pm UTC](https://forum.networklessons.com/t/mac-addresses-on-switch/3421/4 "2018-04-13T20:45:59Z")

</div>

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 does a switch learn MAC Addresses](https://networklessons.com/switching/how-does-a-switch-learn-mac-addresses)**
>
> This lesson explains how a switch learns MAC address and why it floods frames when it doesn't know the destination MAC address.

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:

> **[How to configure port-security on Cisco Switch](https://networklessons.com/switching/how-to-configure-port-security-on-cisco-switch)**
>
> Port-security can be used to filter MAC-addresses on Cisco switches. In this lesson you will learn how it works and how to configure it.

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

> **[Introduction to Routers and Routing](https://networklessons.com/ip-routing/introduction-to-routers-and-routing)**
>
> This lesson explains the basics of routing and routers. What is routing? What's the difference between a router and switch?

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

Rene

---

<div class="post-metadata">

**Author:** ![d.proch1988](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/d.proch1988/32/954_2.png) [@d.proch1988](https://forum.networklessons.com/u/d.proch1988)\
**Post date:** [May 21, 2018, 5:42pm UTC](https://forum.networklessons.com/t/mac-addresses-on-switch/3421/5 "2018-05-21T17:42:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)\
**Post date:** [May 22, 2018, 3:14pm UTC](https://forum.networklessons.com/t/mac-addresses-on-switch/3421/6 "2018-05-22T15:14:04Z")

</div>

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:

> **[InterVLAN Routing](https://networklessons.com/switching/intervlan-routing)**
>
> In this lesson you will learn about the different options there are for routing between VLANS: Router on a stick, SVI interface or L3 interfaces.

Rene

---

<div class="post-metadata">

**Author:** ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)\
**Post date:** [June 12, 2018, 11:02am UTC](https://forum.networklessons.com/t/mac-addresses-on-switch/3421/9 "2018-06-12T11:02:14Z")

</div>

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
