Port Configuration
In this section we’ll walk through configuring a number of common port types.
Tips
Configuring Multiple Ports
Sometimes you may need to configure a bunch of ports with the same configuration. To save time, use the range
command. The following example will configure all ports between gigabitEthernet 1/0/1 and 1/0/10 as access ports on VLAN 100.
Switch (config)# interface range gigabitEthernet 1/0/1 - 10
Switch (config-if-range)# switchport mode access
Switch (config-if)# switchport access vlan 100
Clearing a Port’s Configuration
To clear a ports configuration (colloquially known as defaulting the port), run the default
command. The following example will clear all configurations applied to port gigabitEthernet 1/0/1.
Switch (config)# default interface gigabitEthernet 1/0/1
Access Port
An access port is a port where traffic sent and received is not tagged. An common use case for access ports is endpoint devices such as workstations, printers etc.
Below are the commands to configure an access port. This example specifies that gigabitEthernet 1/0/1 is an access port and all received traffic will be placed onto VLAN 100.
Switch (config)# interface gigabitEthernet 1/0/1
Switch (config-if)# switchport mode access
Switch (config-if)# switchport access vlan 100
Access Port w/ Voice VLAN
A useful feature for IP phones, is using LLDP to automatically configure the IP phone so voice traffic is transmitted over one VLAN, while data from a daisy-chained PC (connected through the phone) is transmitted over another VLAN.
Ensure LLDP is enabled on the switch (enabled by default).
Switch (config)# lldp run
On all access type ports specify the voice VLAN to be used.
Switch (config-if)# switchport voice vlan 101
Below is an example of a fully configured port.
interface gigabitEthernet 1/0/1
switchport mode access
switchport access vlan 100
switchport voice vlan 101
Trunk Port
A trunk port is a port where sent and received traffic can be tagged or untagged. This allows multiple VLAN to communicate across a connection while still maintaining layer two separation. Commonly trunk ports are used when interconnecting switches, or connecting to routers or hypervisors.
Below is an example configuration of a trunk port. In this example port gigabitEthernet 1/0/1 is an trunk port and will accept either tagged or untagged traffic.
Switch (config)# interface gigabitEthernet 1/0/1
Switch (config-if)# switchport mode trunk
For added security, you can specify what VLANs the switch will accept from the connected device.
Switch (config-if)# switchport trunk allowed vlan 100-150,160
Specifying a Native VLAN
In certain configuration you may want to specify where untagged traffic on a trunk port goes. To do this, use the native vlan
command. In the example below all untagged traffic received on the trunk port will be placed onto VLAN 100.
Switch (config-if)# switchport trunk native vlan 100
Port Channel (LACP)
A port-channel allows you combine multiple ports together to both increase the link’s bandwidth (but not speed) and build-in some link redundancy incase one link fails. In the following example, port channel 1 will be created. It will communicate using LACP and be configured as a trunk to allow both tagged and untagged traffic.
First, configure the ports you wish to be included on the port channel. To speed up the process, I’m going to use the range
command.
Switch (config)# interface range gigabitEthernet 1/0/1-2
Switch (config-if-range)# channel-group 1 mode active
Switch (config-if-range)# channel-protocol lacp
Next, specify the configuration of your port-channel.
Switch (config)# interface port-channel 1
Switch (config-if)# switchport mode trunk
Switch (config-if)# switchport trunk allowed vlan 100-150,160
The port channel has been configured.