Cisco Switch Port, VLAN and Trunk Guide
The aim of this article is to give a beginners a brief guide on how to manage Cisco switches. We will cover the following.
- Basic port commands such as accessing ports
- Enabling and disabling ports on Cisco switches
- Creating VLANs on Cisco switches
- Assigning Ip addresses to VLANs
- Adding a port ( interface ) to a VLAN
- Creating a trunk of ports on a Cisco switch
Cisco Switch Port Commands
To manage your Cisco switch you need to understand how you access ports and how you can enable and disable them. Most switches have Fast Ethernet and Gigabit capability, newer switches have the capability of fiber and faster. Bare in mind when trying to access a port you need to take into account the type of port you are trying to access. To start accessing ports we need to start by being in enable mode. From your switch enter the following.
enable
We then need to enter the configure terminal command.
conf t
Your switch will look something like this, we now have access to the commands required to manage Cisco ports.
To access ports we use the Interface command, we then add on the port type which in the case is either Fast Ethernet or Gigabit. Here we will be accessing port 10. To access port 10 if it is Fast Ethernet we issue the command below.
interface fastEthernet 0/10
You will now be in the interface context as seen here.
If port 10 was gigabit we would of issued this command.
interface gigabitEthernet 0/10
Now that we are in the port we would like to configure we can issue the following commands.
To shut down the port issue the below command.
sh
To enable the port again issue the command below.
no sh
We can also enable or disable a range of ports with the following command, here we select port 2-5 then shut them down.
interface range fastEthernet 0/2 -5
To go back to the previous context we issue the exit command. Now that you can access your ports and enable and disable as required we are now ready to create and manage Cisco VLANS.
Creating and Managing Cisco VLANS
Creating VLANS on is very simple, as long as you are in configure terminal you issue the commands as seen below, here we create VLAN 10,20 and 30.
vlan 10,20,30
If we want to assign IP addresses to our VLANS we first need to be in the actual VLAN context, here we configure VLAN 10`s ip address.First we enter vlan 10
int vlan 10
Then we allocate it the address 192.168.10.1 specifying the correct subnet. This is called Cisco VLAN Routing.
IP Address 192.168.10.1 255.255.255.0
To remove the vlan we would use the no command, for example
no vlan 10
To enable routing between our VLANs we would need to enable IP routing.
ip routing
You can now create VLANs and allocate ip address to VLANs for whatever VLANs you create, IP routing is enabled so traffic will flow. We can now create trunk ports to allow VLAN traffic to flow through our ports
Creating Cisco Trunks
In this section we select ports, then we select what VLAN traffic is allowed across these trunks. First we select our ports, we can either select a range or individual ports. To select non concurrent ports use comma “,” between ports as opposed to a hyphen as I use here. Here we select port 10-15 and allow VLAN 10 and 20 to flow, we then allow port 16-20 for VLAN. We set the encapsulation as DOT1q.
int range fastEthernet 0/10 - 15 switchport encapsulation dot1q switchport mode trunk switchport trunk allowed vlan 10,20
If we wanted to remove vlans from cisco trunks then we issue the following command, here we remove VLANs 20 and 30 from ports 10 to 15.
int range fastEthernet 0/10 - 15 no switchport trunk allowed vlan 10,20
For more indepth Cisco Vlan information check out http://www.cisco.com/en/US/docs/switches/lan/catalyst2950/software/release/12.1_9_ea1/configuration/guide/swvlan.html
Tags: Cisco, ports, trunks, vlan
Farhan
| #
I think this website is great!
Reply
IT Guy
| #
Say you have a router that doesn’t talk to vlans, how can you untag the traffic leaving the trunk port?
I have 4 vlans on a 48 port cisco switch, each has it’s own port on the router, with it’s own subnet for each vlan and dhcp servers.
Reply