NOPE LinkedIn

Catégories:
Tips&Tricks
Network

Make a macro to create etherchannel

You should be connected in privileged user in enabled mode The followind command list all the macro present on the equipment.

#sh parser macro brief
default global : cisco-global
default interface: cisco-desktop
default interface: cisco-phone 
default interface: cisco-switch
default interface: cisco-router
default interface: cisco-wireless
customizable : Make_Range_UNUSED
customizable : Make_UNUSED
customizable : make_Firewall_Links

The default ones are Cisco pre-defined and the other ‘customizable’ are user defined. These one have been made to admnister the equipement. To list the content of the macro:

#sh parser macro name make_Firewall_Links
Macro name : make_Firewall_Links
Macro type : customizable
 #
 # Macro to configure an range interfaces in an etherfchannel for Firewall Link
 # To apply this macro on port group 10 and on the port Gi1/0/4 and Gi1/0/5 :
 # macro global trace make_Firewall_Links $Range Gi1/0/4-5 $PoNum 10 $Desc "To Firewall01 MASTER port2"
 #
#
# Configuration of the port in the etherchannel
#
 default int range $Range
 int range $Range
  description *** $Desc ***
  no lldp transmit
  no lldp receive
  no cdp enable
  channel-protocol lacp
  channel-group $PoNum mode active
  spanning-tree portfast
  spanning-tree bpduguard enable
#
# Configuration of the etherchannel port
#
 int po$PoNum
  description *** $Desc ***
  switchport access vlan 100
  switchport mode access
  switchport nonegotiate
  spanning-tree portfast
 end

The command executed to create the macro are:

(config)#macro name make_Firewall_Links
Enter macro commands one per line. End with the character '@'.
#
# Configuration of the port in the etherchannel
#
 default int range $Range
 int range $Range
  description *** $Desc ***
  no lldp transmit
  no lldp receive
  no cdp enable
  channel-protocol lacp
  channel-group $PoNum mode active
  spanning-tree portfast
  spanning-tree bpduguard enable
#
# Configuration of the etherchannel port
#
 int po$PoNum
  description *** $Desc ***
  switchport access vlan 100
  switchport mode access
  switchport nonegotiate
  spanning-tree portfast
#
end
@

end

We are using to port to create an etherchannel link.

#sh inter status
Port      Name               Status       Vlan       Duplex  Speed Type
Gi1/0/24  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/25  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/26  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/27  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/28  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/29  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/30  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/31  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/32  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/33  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/34  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/35  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX

We aer using the port 24 and 30

#conf t
Enter configuration commands, one per line.  End with CNTL/Z.

Let make a try on port 24 and 30

(config)#macro global trace make_Firewall_Links $Range G1/0/24,G1/0/30 $PoNum 21 $Desc "To Firewall01 MASTER port2"
Applying command... ' default int range G1/0/24,G1/0/30'
% Cannot enable CDP on this interface, since CDP is not running
% Cannot enable CDP on this interface, since CDP is not running
Applying command... ' int range G1/0/24,G1/0/30'
Applying command... '  description *** To Firewall01 MASTER port2 ***'
Applying command... '  no lldp transmit'
Applying command... '  no lldp receive'
Applying command... '  no cdp enable'
Applying command... '  channel-protocol lacp'
Applying command... '  channel-group 21 mode active'
Creating a port-channel interface Port-channel 21

Applying command... '  spanning-tree portfast'
%Warning: portfast should only be enabled on ports connected to a single
 host. Connecting hubs, concentrators, switches, bridges, etc... to this
 interface  when portfast is enabled, can cause temporary bridging loops.
 Use with CAUTION

%Portfast will be configured in 1 interfaces due to the range command
 but will only have effect when the interfaces are in a non-trunking mode.
Applying command... '  spanning-tree bpduguard enable'
Applying command... ' int po21'
Applying command... '  description *** To Firewall01 MASTER port2 ***'
Applying command... '  switchport access vlan 100'
Applying command... '  switchport mode access'
Applying command... '  switchport nonegotiate'
Applying command... '  spanning-tree portfast'
%Warning: portfast should only be enabled on ports connected to a single
 host. Connecting hubs, concentrators, switches, bridges, etc... to this
 interface  when portfast is enabled, can cause temporary bridging loops.
 Use with CAUTION

%Portfast has been configured on Port-channel21 but will only
 have effect when the interface is in a non-trunking mode.
Applying command... 'end'

How is configured th etherchannel po21 :

(config)#do sh run inter po21
Building configuration...

Current configuration : 180 bytes
!
interface Port-channel21
 description *** To Firewall01 MASTER port2 ***
 switchport access vlan 100
 switchport mode access
 switchport nonegotiate
 spanning-tree portfast
end

let check

(config)#do sh etherc sum
Flags:  D - down        P - bundled in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        R - Layer3      S - Layer2
        U - in use      f - failed to allocate aggregator

        M - not in use, minimum links not met
        u - unsuitable for bundling
        w - waiting to be aggregated
        d - default port


Number of channel-groups in use: 4
Number of aggregators:           4

Group  Port-channel  Protocol    Ports
------+-------------+-----------+-----------------------------------------------
2      Po2(SD)          -
10     Po10(SD)        LACP      Gi1/0/4(D)  Gi1/0/5(D)  Gi1/0/15(D)
                                 Gi1/0/16(D)
20     Po20(SD)        LACP      Gi1/0/13(D) Gi1/0/14(D)
21     Po21(SD)        LACP      Gi1/0/24(D) Gi1/0/30(D)

and the configuration of the ports:

(config)#do sh run inter g1/0/24
Building configuration...

Current configuration : 322 bytes
!
interface GigabitEthernet1/0/24
 description *** To Firewall01 MASTER port2 ***
 switchport access vlan 100
 switchport mode access
 switchport nonegotiate
 no cdp enable
 no lldp transmit
 no lldp receive
 spanning-tree portfast
 spanning-tree bpduguard enable
 channel-protocol lacp
 channel-group 21 mode active
end

ERC50014(config)#do sh run inter g1/0/30
Building configuration...

Current configuration : 322 bytes
!
interface GigabitEthernet1/0/30
 description *** To Firewall01 MASTER port2 ***
 switchport access vlan 100
 switchport mode access
 switchport nonegotiate
 no cdp enable
 no lldp transmit
 no lldp receive
 spanning-tree portfast
 spanning-tree bpduguard enable
 channel-protocol lacp
 channel-group 21 mode active
end

and the status

(config)#do sh inter status
Port      Name               Status       Vlan       Duplex  Speed Type
Gi1/0/24  *** To Firewall01  notconnect   100          auto   auto 10/100/1000BaseTX
Gi1/0/25  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/26  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/27  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/28  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/29  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/30  *** To Firewall01  notconnect   100          auto   auto 10/100/1000BaseTX
Gi1/0/31  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/32  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/33  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/34  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX
Gi1/0/35  --- UNUSED ---     disabled     111          auto   auto 10/100/1000BaseTX

All Done.