This blog was originally started to better help me understand the technologies in the CCIE R&S blueprint; after completing the R&S track I have decided to transition the blog into a technology blog.

CCIE #29033

This blog will continue to include questions, troubleshooting scenarios, and references to existing and new technologies but will grow to include a variety of different platforms and technologies. Currently I have created over 185 questions/answers in regards to the CCIE R&S track!! Note: answers are in the comment field or within "Read More" section.

You can also follow me on twitter @FE80CC1E


Tuesday, April 27, 2010

Question 48

Create a macro that modifies multiple interfaces with one command?

4 comments:

Unknown said...

Would it be something like this?

Switch(config)#interface range fastethernet0/1 - 10
Switch(config-if-range)#switchport mode access

These commands configure interfaces 1-10 and then enables switchport mode access on all these ports.

You can also issue multiple ranges, separating the command with a comma (,).

Switch(config)#interface range fastethernet0/1 – 5 , fastethernet0/10 – 15

Packets Analyzed said...

Although that will modify multiple interfaces it is not how you would create a macro that can be used later.

Global Config
"define interface-range (macro-name) fa 0/1 - 5, fa 0/8 - 20, gig 0/3 - 4"

To execute use "interface range macro (macro-name)"

To view macros
"show parser macro"
"show parser macro (macro-name)"

Unknown said...

Interesting. I haven't used macros before (I actually didn't know they existed :o ) but they look pretty straightforward to setup and handy.

Can you combine multiple commands in one macro?

Packets Analyzed said...

This is asked in question 47 but I would be happy to include an example

Say you want to create a host port for fas 0/1 - 10 and you wanted the following settings
switchport mode access
switchport access vlan 10
spanning-tree portfast bpduguard
switchport port-security
switchport port-security maximum 1
switchport port-security violation restrict
switchport port-security mac-address sticky

You can create a MACRO to apply this to the interfaces above or other interfaces in the future. This will also allow specify a VLAN

macro name HOSTMACRO
switchport mode access
switchport access vlan $VLAN
spanning-tree portfast bpduguard
switchport port-security
switchport port-security maximum 1
switchport port-security violation restrict
switchport port-security mac-address sticky
no shut
@

To apply it based on the requirement above
interface range fas 0/1 - 10
macro apply HOSTMACRO $VLAN 10

Future use on a different port and vlan
interface inter gig 0/2
macro apply HOSTMACRO $VLAN 222

Post a Comment