<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/interface-mac-address-in-ios-layer-2-images-ipspace-net-blog-zxgjnxahy" -->

---
title: Interface MAC Address in IOS Layer-2 Images «...
description: Cisco IOS layer-2 images have a surprising behavior: the interface MAC address is tied to the switchport status. When you toggle an interface between...
canonical: https://daily.dev/posts/interface-mac-address-in-ios-layer-2-images-ipspace-net-blog-zxgjnxahy
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Interface MAC Address in IOS Layer-2 Images « ipSpace.net blog | daily.dev
og:description: Cisco IOS layer-2 images have a surprising behavior: the interface MAC address is tied to the switchport status. When you toggle an interface between...
og:url: https://daily.dev/posts/interface-mac-address-in-ios-layer-2-images-ipspace-net-blog-zxgjnxahy
og:image: https://api.daily.dev/og/posts/zXGjnXaHy.png
og:image:alt: Interface MAC Address in IOS Layer-2 Images « ipSpace.net blog
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Interface MAC Address in IOS Layer-2 Images « ipSpace.net blog

**[ipSpace.net Blog](https://daily.dev/sources/ipspace)** · 4 min read · 0 upvotes · 0 comments

## Summary

Cisco IOS layer-2 images have a surprising behavior: the interface MAC address is tied to the switchport status. When you toggle an interface between switchport and routed (no switchport) mode, the MAC address configuration silently disappears or reverts. This creates a subtle automation trap — Ansible sees the MAC address as already configured in the normalize phase, skips reapplying it after the switchport change, and the interface ends up with its default MAC address instead of the intended one. The post walks through the exact IOS CLI behavior with show run output and explains how Ansible's idempotency logic compounds the problem.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.ipspace.net/2026/02/ios-layer2-mac-address>

## Questions this post answers

### Does Cisco IOS layer-2 image reset the interface MAC address when I toggle switchport mode?

Yes. In Cisco IOS layer-2 images, the MAC address configuration is tied to the switchport status. When you run `no switchport` on an interface that has a mac-address set, the mac-address command disappears from the running config. When you re-enable switchport, the original switchport MAC address reappears — but any MAC address set in routed mode is lost. Each switchport state maintains its own separate MAC address context.

_Network engineers automating IOS L2 devices track quirks like this on daily.dev before they hit production._

### Why does Ansible not reapply the mac-address command after a no switchport change on Cisco IOS?

Ansible compares the existing device configuration to the desired state before pushing changes. If the mac-address command was already present before the switchport toggle, Ansible marks it as unchanged and skips reapplying it. After IOS silently drops the MAC address due to the switchport state change, Ansible has no mechanism to detect the discrepancy, so the interface ends up using its default MAC address without any error or changed flag.

_Teams building Ansible playbooks for Cisco IOS L2 devices share workarounds like this on daily.dev._

## Similar posts on daily.dev

- [Configuring Management IP Addresses to Virtual Network Devices « ipSpace.net blog](https://daily.dev/posts/configuring-management-ip-addresses-to-virtual-network-devices-ipspace-net-blog-ffffzfuyz) · ipSpace.net Blog · 0 upvotes · 0 comments

---

Tags: [#networking](https://daily.dev/tags/networking), [#ansible](https://daily.dev/tags/ansible)

[View this post on daily.dev](https://daily.dev/posts/interface-mac-address-in-ios-layer-2-images-ipspace-net-blog-zxgjnxahy)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Interface MAC Address in IOS Layer-2 Images « ipSpace.net blog","url":"https://daily.dev/posts/interface-mac-address-in-ios-layer-2-images-ipspace-net-blog-zxgjnxahy","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/interface-mac-address-in-ios-layer-2-images-ipspace-net-blog-zxgjnxahy"},"datePublished":"2026-08-11T08:54:45.966Z","dateModified":"2026-08-11T09:02:25.194Z","description":"Cisco IOS layer-2 images have a surprising behavior: the interface MAC address is tied to the switchport status. When you toggle an interface between...","image":"https://media.daily.dev/image/upload/s--OHB84bZF--/f_auto/v1722860399/public/Placeholder%2010","thumbnailUrl":"https://media.daily.dev/image/upload/s--OHB84bZF--/f_auto/v1722860399/public/Placeholder%2010","isAccessibleForFree":true,"articleSection":"ipSpace.net Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"ipSpace.net Blog","logo":"https://media.daily.dev/image/upload/s--xS7E82MT--/f_auto,q_auto/v1786438303/logos/ipspace?_a=BAMAMicg0","url":"https://daily.dev/sources/ipspace"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/interface-mac-address-in-ios-layer-2-images-ipspace-net-blog-zxgjnxahy","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"networking,ansible","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"ipSpace.net Blog","item":"https://daily.dev/sources/ipspace"},{"@type":"ListItem","position":3,"name":"Interface MAC Address in IOS Layer-2 Images « ipSpace.net blog"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/interface-mac-address-in-ios-layer-2-images-ipspace-net-blog-zxgjnxahy#faq","mainEntity":[{"@type":"Question","name":"Does Cisco IOS layer-2 image reset the interface MAC address when I toggle switchport mode?","acceptedAnswer":{"@type":"Answer","text":"Yes. In Cisco IOS layer-2 images, the MAC address configuration is tied to the switchport status. When you run `no switchport` on an interface that has a mac-address set, the mac-address command disappears from the running config. When you re-enable switchport, the original switchport MAC address reappears — but any MAC address set in routed mode is lost. Each switchport state maintains its own separate MAC address context. Network engineers automating IOS L2 devices track quirks like this on daily.dev before they hit production."}},{"@type":"Question","name":"Why does Ansible not reapply the mac-address command after a no switchport change on Cisco IOS?","acceptedAnswer":{"@type":"Answer","text":"Ansible compares the existing device configuration to the desired state before pushing changes. If the mac-address command was already present before the switchport toggle, Ansible marks it as unchanged and skips reapplying it. After IOS silently drops the MAC address due to the switchport state change, Ansible has no mechanism to detect the discrepancy, so the interface ends up using its default MAC address without any error or changed flag. Teams building Ansible playbooks for Cisco IOS L2 devices share workarounds like this on daily.dev."}}]}
```

