Cisco Macro not executing Interface Range

SteveO86SteveO86 Member Posts: 1,423
This one has been getting to me for a few days now.. I'm trying to get some pre-configured macros on all my switches so when I perform an upgrade and I can just kick off these macros..

The goal of this macro:
1. Remove and shutdown vlan 1
2. create VLANs for users
3. Assign the ports to the desired VLANs

Here is a test macro I am working with:

define interface-range macro1 fa0/1 - 24
define interface-range macro2 gi0/1 - 2 
macro name change_network2
interface Vlan1
   no ip address
   shutdown
interface vlan 11
   description UserNetwork
   ip address 192.168.1.2 255.255.255.0
   no shutdown 
interface vlan 99
   description Null Interface for unused ports
   ip address 172.160.1.2 255.255.255.0
   no shutdown 
Interface range macro macro1
   switchport mode access
   switchport access vlan 30
Interface range macro macro2
   switchport mode trunk
   switchport trunk native vlan 99
   switchport trunk allowed vlan all
   @

When I run this macro I get the following message:
% Command exited out of interface range and its sub-modes.
  Not executing the command for second and later interfaces

Now it applies the configuration only to the first port in the interface range... but that's it. From the Cisco document here it says this:
•Applying a macro to an interface range is the same as applying a macro to a single interface. When you use an interface range, the macro is applied sequentially to each interface within the range. If a macro command fails on one interface, it is still applied to the remaining interfaces.

So I assume this can be done... I just can't find much else on this.. I'm running this a Cisco 2960 IOS 12.2(44).. I suppose I can forget about the interface range command and list the individual interfaces but that doesn't seem right...

(I've also tried it without the define interface range and got the same results)

Any thoughts?
My Networking blog
Latest blog post: Let's review EIGRP Named Mode
Currently Studying: CCNP: Wireless - IUWMS

Comments

  • DPGDPG Member Posts: 780 ■■■■■□□□□□
    Perhaps you can't use shorthand for the define command?

    Try this:

    define interface-range macro1 fastethernet 0/1 - 24
    define interface-range macro2 gigabitethernet 0/1 - 2
  • pitviperpitviper Member Posts: 1,376 ■■■■■■■□□□
    Looks like you can apply a macro within a range command, but can’t use the range command within a macro. I tried your config on a 2960 with the same results. This seems to work though:
    macro name switchport
       switchport mode access
       switchport access vlan 30
       switchport voice vlan 40
       mls qos trust cos
       spanning-tree portfast
    @
    
    int range f0/1-24
    macro apply switchport
    
    CCNP:Collaboration, CCNP:R&S, CCNA:S, CCNA:V, CCNA, CCENT
  • SteveO86SteveO86 Member Posts: 1,423
    DPG wrote: »
    Perhaps you can't use shorthand for the define command?

    Try this:

    define interface-range macro1 fastethernet 0/1 - 24
    define interface-range macro2 gigabitethernet 0/1 - 2

    Tried that one already no difference.

    pitviper wrote: »
    Looks like you can apply a macro within a range command, but can’t use the range command within a macro. I tried your config on a 2960 with the same results. This seems to work though:
    macro name switchport
       switchport mode access
       switchport access vlan 30
       switchport voice vlan 40
       mls qos trust cos
       spanning-tree portfast
    @
    
    int range f0/1-24
    macro apply switchport
    

    Yea, those are the only results I can get working... I wonder why it doesn't work the other way around..

    Thanks for the confirmation!
    My Networking blog
    Latest blog post: Let's review EIGRP Named Mode
    Currently Studying: CCNP: Wireless - IUWMS
Sign In or Register to comment.