How does a switch learn MAC Addresses

Hi guys,

I’ve build a lab with 3 hosts and a L2 switch like the Rene’s lessons but I’ve a couple of issues.

The interfaces of my hosts are fastethernet and the switch has all gigabit,
the speed and the duplex mode are configured as auto in all devices but I still see this error in the switch console:

“duplex mistmatch discovered on the interface…(not full duplex)…”, Should It negotiate automagically the duplex mode??

and after that I can see that my mac address-table is always learning for dynamic mac addresses even with no traffic pruduced by the hosts , I’ve also disabled CDP STP with this commands on SW1:

no spanning-tree valn1
no cdp enable

Can you help me?

Hello Giovanni

Yes, the duplex and speed should automatically negotiate and function correctly. However there are cases where some NICs and switch ports just don’t get along. If you’ve confirmed that configurations are indeed correct, then it could just be an incompatibility of hardware. I suggest the following:

  1. Try to hardwire the duplex mode to full on the swichport and see if the problem is resolved
  2. PC NICs can also be configured to be auto/half/full - if you go into the network adaptor admin of the PCs, verify that they are indeed set to auto
  3. The “duplex mistmatch discovered on the interface” message sounds like a CDP message to me, but you said that you disabled CDP. Does it look something like this?
    %CDP-4-DUPLEX_MISMATCH: duplex mismatch discovered on GigabitEthernet0/0 (not full duplex)
    If so, you may be running into the problem on a port that is connected to another Cisco switch or router. Verify that this is not the case and verify that CDP has been disabled on the appropriate port (if you want to disable CDP).

Hosts will always send and receive some level of traffic, even if you don’t initiate any applications on the device. Even if you disable STP and CDP, NIC cards will always be sending some information such as gratuitous ARP requests for example. If you have IPv6 enabled, it will attempt to find the local router as well as other devices on the network. These are all functions that are put in place by the operating system of the host as “housekeeping” routines, so you will almost always see traffic coming from the host, and thus the MAC address table being populated as a result.

I hope this has been helpful!

Laz

Hi
I think that the issue about the mismatch is releated at the GNS3 enviroment.

Thank you again, for now I will disable cdp :slight_smile:

Hello Giovanni,
if you are using routers with fastethernet interfaces, configure their interfaces like this:

! on router interface
interface fa0/0
 duplex full
 speed 100

On switch interfaces disable autonegotiation and hardcode duplex and speed.

! on switch interface
interface g0/1
 no negotiation auto
 duplex full
 speed 100

This should fix your issue.

I’ve fixed thank you.

I have only to disable the negotiation on switches, no anymore cdp errors

A post was merged into an existing topic: Collision Domain

Hi,

how to ping mac address in Cisco devices?

Hi,
You cannot ping a mac-address because it works on layer-3.

When you perform a ping to an X.X.X.X the device do the arp-request (at layer2) to find the mac address with this IP.

You can check mac addresses with:
show mac address-table

and the arp entries with
show arp [vlan <X>]

Bye

okey .so its not possible to ping mac address directly right?

Yes, it is not possible.

Hello Gowthamraj

@obertigiovannicesare is right, you can’t ping a host using the MAC address. Ping uses the ICMP protocol and functions at Layer 3. It is designed to send echo requests and echo replies and uses IP addresses as the source and destination of these messages. More about ping can be found at the following lesson.

However, you can ping a particular MAC address “indirectly”. If you know the MAC address you’re looking for, you can find IP address that corresponds to it using Address Resolution Protocol (ARP). Once you find this, you can ping that IP address, and if you get a response, you can be sure that the MAC address of that host has been successfully reached.

Remember that IP communication relies on the underlying Ethernet communication that uses the source and destination MAC addresses, so all IP communications have an underlying Layer 2 component.

I hope this has been helpful!

Laz

Hi,
How are you …Hope everything in your end.Could you please check the below and advise.
You are here: Home » Cisco » CCIE Enterprise Infrastructure
How does a switch learn MAC Addresses

SW1#show mac address-table dynamic  
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   1    fa16.3e02.9079    DYNAMIC     Gi0/3
   1    fa16.3e31.cdd8    DYNAMIC     Gi0/2
   1    fa16.3e40.f97d    DYNAMIC     Gi0/1
   1    fa16.3eb9.eacd    DYNAMIC     Gi0/3
Total Mac Addresses for this criterion: 5

Total Mac Address of this creation should be - 4

Hello Amjed

Thanks for pointing that one out, I will let Rene know to correct it.

Laz

@ReneMolenaar Why MAC address is required when we have IP address to communicate ? or Why IP address is required, can’t we communicate on the basis of MAC address only ?

Hello M M

The MAC and IP addresses are used together to allow network devices to communicate with each other. IP addresses allow the communication from end to end while MAC addresses are used within a specific subnet.

Think about it this way. If I was to give you my postal address, and I told you the number of my house on my street is 176, that would not give you enough information for you to find me. If you had already reached my street, then yes, you could find me with just that information.

The same is true of the MAC address. If I gave you the MAC address of my web server, you would not be able to reach it from your computer. But if I gave you my IP address, you would reach my network, and then using the MAC address (learned via ARP), you could communicate with the specific device on my network.

Remember that network communication functions in layers. The Network Layer is responsible for routing from end to end of a communication, and uses the IP protocol, while the Data link layer, where MAC addresses are used, is responsible for getting a frame to the appropriate device within a network segment.

It is indeed difficult to get your head around it especially if it is the first time you are going over these topics. It will take time, but I suggest you go over the following lessons which will help you understand more fully:


Also, take a look at the CCNA course linked below, and focus on Unit 2: Network fundamentals, which includes all of this information.


I hope this has been helpful!

Laz

Hi Laz,

I have a question here is that, can switch simultaneously learn multiple mac on single interface yes then how much at a time until aging timer expired ?

Hello Pradyumna

Yes, a switch can indeed learn multiple MAC addresses on a single port. For example, if you have two switches connected together, and you have 10 hosts connected to one switch, and 10 connected to the other, the ports connecting the two switches will register multiple MAC addresses in the MAC address table, whenever there is communication between hosts on each switch.

The ageing timer for MAC addresses remains the same (300 seconds by default) and is not affected by the number of MAC addresses that may register in the MAC address table on a particular interface.

I hope this has been helpful!

Laz

Thanks Laz clearly get it

Hi Dear,
In example explained by you in this lesson, you said a switch is a layer 2 device how a layer 2 device is utilizing layer 3 ICMP utility (Ping)? If its not L3/manageable switch?
Please Explain

Hello Ntlipcore

There are various concepts you mention in your post that require clarification in order to understand the concept of Layer 2 and Layer 3 devices.

  • A managed switch is a switch that you can connect to a management interface and change its configuration. A managed switch can be a Layer 2 switch or a Layer 3 switch.
  • A managed Layer 2 switch must be able to have an IP address, so that you can connect to it using Telnet or SSH (or HTTP as well) in order to configure it over the network. On a Cisco switch, this is typically done by creating an SVI on one of the VLANs and assigning it an IP address. This means that the switch, even though it is Layer 2, can ping to and from its IP address.
  • A Layer 3 switch is one that can perform inter-VLAN routing. A Layer 2 switch cannot.

I hope this has been helpful!

Laz

1 Like