Cisco 3550, 4000, and 4500 Series Switches
To put an interface that is in Layer 3 mode into Layer 2 mode for Layer 2 configuration, use the switchport command in interface configuration mode. To put an interface into Layer 3 mode, use the no form of this command.
Cisco Catalyst 6500 and 6000 Series Switches and Cisco 7600 Series Routers
To modify the switching characteristics of the Layer 2-switched interface, use the
switchport command (without keywords). Use the
no form of this command (without keywords) to return the interface to the routed-interface status and cause all further Layer
2 configuration to be erased. Use the
switchport commands (with keywords) to configure the switching characteristics.
switchport
switchport {host | nonegotiate}
no switchport
no switchport nonegotiate
Cisco UCS E-Series Server Installed in Cisco 4400 Integrated Services Routers
To configure the server module to communicate with the router over a high-speed Multi Gigabit Fabric (MGF) backplane switch
port, use the
switchport command (with keywords) in interface configuration mode.
switchport {access | mode | trunk}
Cisco 1000 Series Integrated Services Routers with 4 or 8 Front-Panel Switch Ports
To configure the flex Layer 2 and Layer 3 ports to Layer 2 interface, use the switchport command (without keywords). To configure to Layer 3 interface, use the no
switchport command (without keywords).
Syntax Description
Cisco 3550, 4000, and 4500 Series Switches
This command has no arguments or keywords.
Cisco Catalyst 6500 and 6000 Series Switches and Cisco 7600 Series Routers
Table 1. Syntax Description for Cisco Catalyst 6500 and 6000 Series Switches and Cisco 7600 Series Routers
host
|
Optimizes the port configuration for a host connection.
|
nonegotiate
|
Specifies that the device will not engage in negotiation protocol on this interface.
|
Cisco UCS E-Series Server Installed in Cisco 4400 Integrated Services Routers
Table 2. Syntax Description for Cisco UCS E-Series Server Installed in Cisco 4400 Integrated Services Routers
access
|
Sets the access mode characteristics of the interface.
|
mode
|
Sets the interface type: Access or Trunk.
|
trunk
|
Sets trunk characteristics when the interface is in Trunk mode.
This is the default mode.
|
Cisco 1000 Series Integrated Services Routers with 4 or 8 Front-Panel Switch Ports
This command has no arguments or keywords.
Command Default
Cisco 3550, 4000, and 4500 Series Switches
All interfaces are in Layer 2 mode.
Catalyst 6500/6000 Series Switches and 7600 Series Routers
The default access VLAN and trunk-interface native VLAN are default VLANs that correspond to the platform or interface hardware.
Cisco 1000 Series Integrated Services Routers with 4 or 8 Front-Panel Switch Ports
The last two ports of the front-panel switch ports (flex ports) are set to Layer 2 interface by default.
Command Modes
Interface configuration (config-if)
Command History
Release
|
Modification
|
12.1(4)EA1
|
This command was introduced.
|
12.2(14)SX
|
Support for this command was introduced on the Supervisor Engine 720.
|
12.2(15)ZJ
|
This command was implemented on Cisco 2600 series, Cisco 3600 series, and Cisco 3700 series routers.
|
12.2(17d)SXB
|
Support for this command on the Supervisor Engine 2 was extended to Cisco IOS Release 12.2(17d)SXB.
|
12.3(4)T
|
This command was integrated into Cisco IOS Release 12.3(4)T on the following platforms: Cisco 2600 series, Cisco 3600 series,
and Cisco 3700 series routers.
|
15.1(2)T
|
Support for IPv6 was added.
|
Cisco IOS XE Release 3.9S
|
This command was implemented on Cisco UCS E-Series Servers installed in the Cisco 4400 Series Integrated Services Routers
(ISR).
|
Cisco IOS XE Release 17.11.1a
|
This command was implemented to provide flex support on the last two Layer 2 switch ports of the Cisco 1000 Series ISRs with
4 or 8 Front-Panel Switch Ports.
|
Usage Guidelines
Cisco 3550, 4000, and 4500 Series Switches
Use the
no switchport command to put the interface into the routed-interface status and to erase all Layer 2 configurations. You must use this
command before assigning an IP address to a routed port. Entering the
no switchport command shuts down the port and then reenables it, which might generate messages on the device to which the port is connected.
You can verify the switchport status of an interface by entering the
show running-config privileged EXEC command.
Cisco Catalyst 6500 and 6000 Series Switches and Cisco 7600 Series Routers
You must enter the
switchport command without any keywords to configure the LAN interface as a Layer 2 interface before you can enter additional
switchport commands with keywords. This action is required only if you have not entered the
switchport command for the interface.
Entering the
no switchport command shuts down the port and then reenables it. This action may generate messages on the device to which the port is connected.
To optimize the port configuration, entering the
switchport host command sets the switch port mode to access, enables spanning tree PortFast, and disables channel grouping. Only an end station
can accept this configuration.
Because spanning-tree PortFast is enabled, you should enter the
switchport host command only on ports that are connected to a single host. Connecting other Cisco 7600 series routers, hubs, concentrators,
switches, and bridges to a fast-start port can cause temporary spanning-tree loops.
Enable the
switchport host command to decrease the time that it takes to start up packet forwarding.
The no form of the
switchport nonegotiate command removes nonegotiate status.
When using the
nonegotiate keyword, Dynamic Inter-Switch Link Protocol and Dynamic Trunking Protocol (DISL/DTP)-negotiation packets are not sent on
the interface. The device trunks or does not trunk according to the mode parameter given: access or trunk. This command returns
an error if you attempt to execute it in dynamic (auto or desirable) mode.
You must force a port to trunk before you can configure it as a SPAN-destination port. Use the
switchport nonegotiate command to force the port to trunk.
Examples
The following example shows how to cause an interface to cease operating as a Layer 2 port and become a Cisco-routed (Layer
3) port:
Router(config-if)#no switchport
Examples
The following example shows how to cause the port interface to stop operating as a Cisco-routed port and convert to a Layer
2-switched interface:
Router(config-if)#
switchport
Router(config-if)#
Note
|
The
switchport command is not used on platforms that do not support Cisco-routed ports. All physical ports on such platforms are assumed
to be Layer 2-switched interfaces.
|
The following example shows how to optimize the port configuration for a host connection:
Router(config-if)# switchport host
switchport mode will be set to access
spanning-tree portfast will be enabled
channel group will be disabled
Router(config-if)#
This example shows how to cause a port interface that has already been configured as a switched interface to refrain from
negotiating trunking mode and act as a trunk or access port (depending on the mode set):
Router(config-if)#
switchport nonegotiate
Router(config-if)#
The following example shows how to cause an interface to cease operating as a Cisco-routed port and to convert it into a
Layer 2 switched interface:
Router(config-if)#
switchport
Note
|
The
switchport command is not used on platforms that do not support Cisco-routed (Layer 3) ports. All physical ports on such platforms are
assumed to be Layer 2 switched interfaces.
|
Examples
The following example shows how to set the interface to
access mode:
Router#configure terminal
Router(config)# interface ucse 1/0/0
Router(config-if)# switchport mode access
The following example shows how to set the interface to
trunk mode:
Router#configure terminal
Router(config)# interface ucse 1/0/0
Router(config-if)# switchport mode trunk
Examples
The following example shows how to convert a flex port to a Layer 3 port:
Device# configure terminal
Device(config)# interface GigabitEthernet 0/1/6
Device(config-if)# no switchport
Device(config-if)# ip address 10.10.0.1 255.255.255.0
Device(config-if)# exit
The following example shows how to convert a flex port to a Layer 2 port:
Device# configure terminal
Device(config)# interface GigabitEthernet 0/1/6
Device(config-if)# switchport
Device(config-if)# switchport mode access
Device(config-if)# exit