Cisco switch VLAN basic configuration

Cisco switch VLAN basic configuration

illustrate

  • S1>command in user mode
  • S1#command in privileged mode
  • S1(config)#Mode command for global configuration

For the entry methods of the three modes, refer to the previous article on basic configuration

Create VLANs

Create a single VLAN

Take creating Vlan 10 as an example

S1(config)#vlan 10

will then enter config-vlanthe mode

Name the vlan Test

S1(config-vlan)#name Test

Note that the configuration does not take effect until the mode exits

S1(config-vlan)#exit

Create multiple VLANs

To create multiple VLANs at one time, you can execute the following command (here take 20,30,40 as an example)

S1(config)#vlan 20,30,40

Note: The above command will take effect in the actual Cisco device, but an error will be reported in the emulator

Assign port to VLAN

specify a port

Enter the port, take f0/1 as an example

S1(config)#interface f0/1

For Cisco switch ports, the default mode is dynamic negotiation mode. If the port is connected to a terminal, it is recommended to enable accessthe mode.

S1(config-if)#switchport mode access

Then execute the following command to assign the port to the VLAN

S1(config-if)#switchport access vlan 10

Specify multiple ports

To specify multiple ports, just follow interfacethe command with multiple ports.

For example, we assign both f0/2 and f0/3 ports to vlan10

S1(config)#interface range f0/2,f0/3
S1(config-if-range)#switchport mode access
S1(config-if-range)#switchport access vlan 10

If you specify several consecutive ports, such as f0/4 to f0/8, you can write like this

S1(config)#interface range f0/4-f0/8
S1(config-if-range)#switchport mode access
S1(config-if-range)#switchport access vlan 10

Check VLAN configuration

details

S1#show vlan

summary information

S1# show vlan brief

port status

Use the following command to get the vlan status of the port

S1#show interfaces f0/1 switchport

Voice VLAN Configuration

The network topology can be as follows

The switch is connected to the F0/1 port of the IP phone, and we will create a Vlan 150 next

S2(config)#vlan 150
S2(config-vlan)#name VOICE
S2(config-vlan)#exit

Assign the port to Vlan 150

S2(config)#interface f0/1
S2(config-if)#mls qos trust cos
S2(config-if)#switchport voice vlan 150

mls qos trust cosIt refers to the COS carried in the trust data package.

Trunk configuration

mode configuration

Take port f0/3 as an example

S1(config)#interface f0/3
S1(config-if)#switch mode trunk
S1(config-if)#switch nonegotiate

switchport nonegotiateIt is equivalent to turning off DTP, reducing negotiation traffic and increasing security

Configure allowed VLAN

Cisco devices allow all VLANs to be transmitted on the trunk link by default, and the corresponding commands are as follows

S1(config-if)#switchport trunk allowed vlan all

If you want to ban all VLANs, the command is as follows

S1(config-if)#switchport trunk allowed vlan none

Add a certain VLAN, such as Vlan 10

S1(config-if)#switchport trunk allowed vlan add 10

Delete a VLAN, such as Vlan 10

S1(config-if)#switchport trunk allowed vlan remove 10

Another command is all VLANs except a certain Vlan

For example, this configuration allows all VLANs except Vlan 10

S1(config-if)#switchport trunk allowed vlan except 10

Specify native VLAN

Note here:

  • Intrinsic Vlan do not use Vlan 1
  • Use a VLAN without users as a native VLAN
  • The native VLANs at both ends of 802.1Q must be the same

Suppose you want to specify Vlan 10 as the intrinsic Vlan, the command is as follows:

S1(config-if)#switchport trunk native vlan 10

Guess you like

Origin blog.csdn.net/qq_42759112/article/details/127437666