Configure a Vlan for a Cisco Switch

Source: Internet
Author: User
Tags cisco switch
* Vlan configuration ideas (access and Trunk) (1) create a Vlan and configure a static VLAN on an IOS-based switch: switch # vlandatabaseswitch (vlan) # vlanvlan-numnamevlan-nameswitch (vlan) # exitswitch # configureteriminalswitch (config) # interfaceinterfacemodu

* Vlan configuration ideas (access and Trunk) (1) create a Vlan and configure a static VLAN on the IOS-based switch: switch # vlan database switch (vlan) # vlan-num name vlan-name switch (vlan) # exit switch # configure teriminal switch (config) # interface modu

* VlanConfigurationConcept (access, Trunk)

(1) create a Vlan

In IOS-basedVswitchUpperConfigurationStatic VLAN:

Switch # vlan database

Switch (vlan) # vlan-num name vlan-name

Switch (vlan) # exit

Switch # configure teriminal

Switch (config) # interface module/number

Switch (config-if) # switchport mode access // set the port mode to access

Switch (config-if) # switchport access vlan-num // set the vlan to which the port belongs

Switch (config-if) # end

VerificationConfiguration: Show vlan

(2)ConfigurationTrunk Link

Dry track is in two catalystVswitchPort or catalystVswitchA point-to-point link with the router. Trunk links can carry multiple VLANs.

In IOS-basedVswitchUpperConfigurationTrunk Link

Switch (config) # interface mod/port

Switch (config-if) # switchport modeTrunk// Set the port modeTrunkMode

Switch (config-if) # switchport trunk encapsulation {isl dotlq} // set the frame encapsulated by trunk

Switch (config-if) # switchport trunk allowed vlan remove vlan-list // allow those VLANs to pass through trunk

(Appendix: switchport trunk allowed vlan {add all outer t remove} vlan-list)

* No switchport

No switchport // change the physical port to a layer-3 Port, that is, the layer-3 port is used as the port on the router.ConfigurationAfter the layer-3 port is configured, you can allocate an IP address on the port. Of course, you can still connect to the PC ,. Router port: indicates a physical portConfigurationThe port generated by the no switchport command in the status. All the three layers require IP addresses for Route exchange.

ConfigurationExample:

Switch # configure terminal

Switch (config) # interface gigabitethernet0/2

Switch (config-if) # no switchport

Switch (config-if) # ip address 192.20.135.21 255.255.255.0

Switch (config-if) # no shutdown

Switch (config-if) # end

Appendix: show interfaces [interface-id] switchport // display the status of the L2 port, which can be used to determine whether the port is a L2 or L3 port. Eg: Switch # show interfaces fastethernet 0/1 switchport

* Layer 3VswitchVLAN settings

(1) Method 1: GeneralConfiguration

Switch # configure terminal

Switch (config) # vlan 20

Switch (config-vlan) # name test20

Switch (config-vlan) # ip address 1.1.1.1 255.255.255.0

Switch (config-vlan) # end

Method 2: enable VLANConfiguration:

Switch # vlan database // enter the VLANConfigurationStatus

Switch (vlan) # vlan 20 name test20 // Add the vlan id and VLAN name

Switch (vlan) # exit update the VLAN database and exit

(2) allocate a port to a VLAN

Switch # configure terminal

Switch (config) # interface fastethernet0/1

Switch (config-if) # switchport mode access // defines the working mode of the L2 port as the access mode

Switch (config-if) # switchport access vlan 2 // assign a port to a VLAN

Switch (config-if) # end

Switch #

(3)ConfigurationVLAN Trunks

Switch # configure terminal

Switch (config) # interface fastethernet0/4

Switch (config-if) # switchport mode trunk

Switch (config-if) # switchport trunk encapsulation dot1q

Switch (config-if) # end

Appendix: switchport trunk encapsulation {isl dot1q negotiate }//ConfigurationTrunk encapsulates ISL or 802.1Q or automatically negotiates

Switchport mode {dynamic {auto desirable} trunk} (usually not used ),ConfigurationLayer 2 trunk mode. (Dynamic auto-automatically negotiate whether it is a trunk; dynamic desirable-set the port to trunk if the peer port is trunk, desirable, or automatic mode; trunk-set the port to the forced trunk mode, regardless of whether the other port is trunk)

(4) define the VLAN allowed by the trunk

Switch (config) # interface fastethernet0/1

Switch (config-if) # switchport trunk allowed vlan remove 2 //ConfigurationVLAN allowed by trunk

Switch (config-if) # end

Appendix: switchport trunk allowed vlan {add all subnet t remove} vlan-list

(5)ConfigurationNative VLAN (802.1q)

Switch (config-if) # switchport trunk native vlan-num // The trunk port that encapsulates 802.1q can accept data streams with or without tags,VswitchTransmits unlabeled data streams to the native vlan. By default, the native VLAN is VLAN 1.

Use no switchport trunk native vlan PortConfigurationThe command returns to the default status.

(6)ConfigurationA group of Ports

4006 # configure terminal

4006 (config) # interface range fastethernet2/1-5

4006 (config-if-range) # no shutdown

// Note: a space must be added between the port numbers. For example, interface range fastethernet 2/1-5 is valid, while interface range fastethernet 2/1-5 is invalid.

The following example shows how to use a commaConfigurationGroups with different port types:

4006 # configure terminal

4006 (config) # interface range fastethernet2/1-3, gigabitethernet3/1-2

4006 (config-if-range) # no shutdown

(7) Other Common commands

Duplex {auto full half} // set full or half duplex.

Speed {10 100 1000 auto nonegotiate} sets the port speed // Note: 1000 only works on Gigabit ports. the GBIC module only works at 1000 Mbps. nonegotiate can only use 1000BASE-SX,-LX, and-zx gbic on these GBIC.

Copy running-config startup-config // Save settings

(8)ConfigurationEtherChannel

Several Ethernet ports are bound to an independent Logical Link. For example, 4006Vswitch, You can bind up to eight compatible ports with the same speed on any module of 4006. Each Ethernet channel has a port-channel port number. To bind an Ethernet channel, a logical port-channel is generated.ConfigurationIt can affect the bound physical ports, butConfigurationThe logical port cannot be affected.Configuration.

1) layer-3 Ethernet channel (logical port-channe)Configuration

Switch # configure terminal

Switch (config) # interface port-channel 1 // create a logical port

Switch (config-if) # ip address 172.32.52.10 255.255.255.0

Switch (config-if) # end

2) layer-3 physical portConfiguration

Switch # configure terminal

Switch (config) # interface range fastethernet 5/4-5 (Note: spaces are required)

Switch (config-if) # no switchport // change the port to a layer-3 Interface

Switch (config-if) # no ip address // confirm that the interface does not existConfigurationIP address

Switch (config-if) # channel-group 1 mode desirable

Switch (config-if) # end

Appendix: Switch (config-if) # channel-group port_channel_number mode {auto desirable on} // Add the physical port to an Ethernet channel and determine the PagP mode.

3) layer-2 Ethernet ChannelConfiguration

Switch # configure terminal

Switch (config) # interface range fastethernet 5/6-7 (Note: spaces are required)

Switch (config-if-range) # channel-group 2 mode desirable

Switch (config-if-range) # end

Switch # show running-config interface port-channel 2

Building configuration...

Current configuration:

!

Interface Port-channel2

Switchport access vlan 10

Switchport mode access

End

Switch #

* How to implement port Aggregation

If you want ConfigurationThe Trunk connection between the two 6509 sets is first connected with gigabit optical fiber, and then respectively ConfigurationThe trunk of the BIND port can use only one pair of optical fiber, or use two pairs of optical fiber as the port channel, ConfigurationAs follows:

When a pair of optical fiber cables are connected Configuration:

Interface GigabitEthernet1/1

No ip address

Switchport

Switchport trunk encapsulation dot1q

Switchport trunk native vlan 1

When connecting two pairs of optical fibers, the port channel must be used to perform the following operations on two 65 Configuration:

Interface port-channe1

No ip address

Switchport

Switchport trunk encapsulation dot1q

Switchport trunk native vlan 1

!

Interface GigabitEthernet1/1

No ip address

Duplex full

Speed1000

Switchport mode trunk

Switchport trunk encapsulation dot1q

Switchport trunk native vlan 1

Channel-group 1 mode on

!

Interface GigabitEthernet1/2

No ip address

Duplex full

Speed1000

Switchport mode trunk

Switchport trunk encapsulation dot1q

Switchport trunk native vlan 1

Channel-group 1 mode on

* VTP Cropping

(1) In IOS-based VswitchUpper ConfigurationVTP mode:

Switch # vlan database

Switch (vlan) # vtp domain-name

Switch (vlan) # vtp {sever cilent transparent}

Switch (vlan) # vtp password

In the CLI-based VswitchUpper ConfigurationVTP mode:

Switch (enable) set vtp [domain-name] [mode {sever cilent transparent}] [password]

(2) In IOS-based VswitchUpper ConfigurationVTP version:

Switch # vlan database

Switch (vlan) # vtp v2-mode

In the CLI-based VswitchUpper ConfigurationVTP version:

Switch (enable) set vtp v2 enable

(3) In IOS-based VswitchStart VTP cropping on:

Switch # vlan database

Switch (vlan) # vtp pruning

In the CLI-based VswitchStart VTP cropping on:

Switch (enable) set vtp pruning enable

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.