cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
565
Views
1
Helpful
5
Replies

conditional config in cisco switch 2960

hamideghbalian
Level 1
Level 1

hi all , i want to config cisco switch as if the port is trunk some situation is met (what i want), otherwise (port is access) some other sitution is met.

for example if the port is access just config sw por max 1 and if the port is trunk just sw mode trunk encapluation dot.1q...

ane ideas?

i want for group config switches

5 Replies 5

config two template, 
config one template under access port 
config other template under trunk port 

I have a lot of switches.And I want to configure all the ports as a group. And I want it to be checked before the configuration, what configuration to use if it was an access port and what configuration to use if it was a trunk port.

IOU1#show run
IOU1#show running-config '
^
% Invalid input detected at '^' marker.

IOU1#show running-config
Building configuration...

Current configuration : 1972 bytes
!
! Last configuration change at 15:13:45 UTC Sat Jul 8 2023
!
version 15.2
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
service compress-config
!
hostname IOU1
!
boot-start-marker
boot-end-marker
!
!
logging discriminator EXCESS severity drops 6 msg-body drops EXCESSCOLL
logging buffered 50000
logging console discriminator EXCESS
!
no aaa new-model
!
!
!
!
!
no ip icmp rate-limit unreachable
!
!
!
no ip domain-lookup
ip cef
no ipv6 cef
!
!
!
spanning-tree mode rapid-pvst
spanning-tree extend system-id
!
vlan internal allocation policy ascending
!
ip tcp synwait-time 5
!
!
!
!
!
!
!
!
!
!
!
!
!
template trunk1
switchport trunk allowed vlan 10,20
switchport trunk encapsulation dot1q
switchport mode trunk
!
template trunk2
switchport trunk allowed vlan 30,40
switchport trunk encapsulation dot1q
switchport mode trunk
!
template vlan10
switchport access vlan 10
!
template vlan20
switchport access vlan 20
!
!
interface Ethernet0/0
source template vlan10
!
interface Ethernet0/1
source template vlan10
!
interface Ethernet0/2
source template vlan10
!
interface Ethernet0/3
source template vlan10
!
interface Ethernet1/0
source template vlan20
!
interface Ethernet1/1
source template vlan20
!
interface Ethernet1/2
source template vlan20
!
interface Ethernet1/3
source template vlan20
!
interface Ethernet2/0
source template trunk1
!
interface Ethernet2/1
source template trunk1
!
interface Ethernet2/2
source template trunk1
!
interface Ethernet2/3
source template trunk1
!
interface Ethernet3/0
!
interface Ethernet3/1
!
interface Ethernet3/2
!
interface Ethernet3/3
!
interface Vlan1
no ip address
shutdown
!
ip forward-protocol nd
!
!
no ip http server
no ip http secure-server
!
!
!
!
!
control-plane
!
!
line con 0
exec-timeout 0 0
privilege level 15
logging synchronous
line aux 0
exec-timeout 0 0
privilege level 15
logging synchronous
line vty 0 4
login
!

Screenshot (915).png

below simple lab, it easy to use template,
please careful when config trunk template, any misconfig will lead to L2 LOOP. 
double check before apply template for trunk

M02@rt37
VIP
VIP

Hello @hamideghbalian

depend of your IOS release, you should have this:

https://content.cisco.com/chapter.sjs?uri=/searchable/chapter/content/en/us/td/docs/ios-xml/ios/ibns/configuration/15-e/ibns-15-e-book/ibns-int-temp.html.xml

Best regards
.ı|ı.ı|ı. If This Helps, Please Rate .ı|ı.ı|ı.
Review Cisco Networking for a $25 gift card