CCNA所要求的交換機型號為CISCO2950
1.配置IP地址
wg_sw_2950(config)#interface vlan 1
wg_sw_2950(config-if)#ip address {ip_address} {mask}
wg_sw_2950(config)#interface vlan 1
wg_sw_2950(config-if)#ip address 10.5.5.11 255.255.255.0
Showing the Switch IP Address
wg_sw_2950#show interface vlan 1
Vlan1 is up, line protocol is up
Hardware is Cat5k Virtual Ethernet, address is 0010.f6a9.9800 (bia 0010.f6a9.9800)
Internet address is 10.5.5.11/24
. . .
wg_sw_2950#
2.配置交換機的端口雙工
wg_sw_2950(config)#interface fa0/1
wg_sw_2950(config-if)#duplex {auto | full | half} //自適應/全雙工/半雙工
3.設置永久MAC地址—不過期
如:
wg_sw_2950(config)#mac-address-table static
mac_addr {vlan vlan_id} [interface int1 [int2 ... int15]]
sw2950(config)#mac-address-table static 1111.1111.1111 vlan 1 interface f0/1
4.管理MAC地址表
sw2950#show mac-address-table
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
All 000f.72db.4ec0 STATIC CPU
All 0100.0ccc.cccc STATIC CPU
All 0100.0ccc.cccd STATIC CPU
All 0100.0cdd.dddd STATIC CPU
1 0000.0c3f.0b05 DYNAMIC Fa0/12
1 0030.94e6.391d DYNAMIC Fa0/11
1 00e0.b05a.5bfe DYNAMIC Fa0/10
Total Mac Addresses for this criterion: 7
sw2950#
5.設置交換機端口的訪問模式(三種) access /dynamic / trunk
(一般交換機與交換機相連接的端口要設置為trunk模式)
SW2950(config-if)#switchport mode ?
access Set trunking mode to ACCESS unconditionally
dynamic Set trunking mode to dynamically negotiate access or trunk mode
trunk Set trunking mode to TRUNK unconditionally
如:
SW2950#config t
SW2950(config)#int fastEthernet 0/1
SW2950(config-if)#switchport mode access //設置FA0/1為ACCESS模式
SW2950(config-if)#switchport mode trunk //設置FA0/1為TRUNK模式
SW2950(config-if)#switchport mode dynamic auto //設置FA0/1為自動直協商模式
(一般交換機與交換機相連接的端口要設置為trunk模式)如下圖:
SW1(config-if)#switchport mode trunk //設置FA0/24為TRUNK模式
SW2(config-if)#switchport mode trunk //設置FA0/24為TRUNK模式
6.配置VLAN
1.創建VLAN
sw(config)#vlan 2 //創建VLAN2
Sw(config)#name VLAN2 //命名為VLAN2,默認為vlan002
2.將端口加入VLAN
sw(config-if)#switchport mode access //設配端口為access模式
sw(config-if)#switchport access vlan 2 //把端口加到vlan2
3.檢查的命令
Switch#show vlan
如:
SW2950#
SW2950#config t
SW2950(config)#vlan 2
SW2950(config-vlan)#name wisdom
SW2950(config-vlan)#exit
SW2950(config)#vlan 3
SW2950(config-vlan)#name market
SW2950(config-vlan)#exit
SW2950(config)#int fas0/4
SW2950(config-if)#switchport mode access
SW2950(config-if)#switchport access vlan 2
SW2950(config-if)#exit
SW2950(config)#interface range fastEthernet 0/10 – 15 //可以同時把多個端口加入到一個VLAN裡
SW2950(config-if-range)#switchport mode access
SW2950(config-if-range)#switchport access vlan 3 //把端口10-15都加入到VLAN3裡
SW2950(config-if-range)#end
SW2950#show vlan //檢查VLAN信息
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/5, Fa0/6, Fa0/7
Fa0/8, Fa0/9, Fa0/16, Fa0/17
Fa0/18, Fa0/19, Fa0/20, Fa0/21
Fa0/22, Fa0/23, Fa0/24
2 wisdom active Fa0/4
3 market active Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/14, Fa0/15
SW2950#
7.配置VTP----VTP技術使得在大型的網絡里布置多個VLAN變得簡單.
VTP的配置步驟:
1、配置Trunk
2、配置VTP DOMAIN
3、配置VTP MODE
4、配置VLAN
5、將端口加入VLAN
6、檢查
Switch#show interface xx/xx switchport
Switch#show vtp status
Switch#show vlan
配置SW1:
SW1#configure terminal
SW1(config)#interface fastEthernet 0/1
SW1(config-if)#switchport mode trunk
SW1(config-if)#no shutdown
SW1(config-if)#exit
SW1(config)#vtp domain wisdom
Domain name already set to wisdom.
SW1(config)#vtp mode server
Device mode already VTP SERVER.
SW1(config)#vtp password cisco
Setting device VLAN database password to cisco
SW1(config)#vtp pruning //配置VTP的修剪,只要在SERVER端配置就行.
Pruning switched on
SW1#sho vtp status
VTP Version : 2
Configuration Revision : 15
Maximum VLANs supported locally : 64
Number of existing VLANs : 5
VTP Operating Mode : Server
VTP Domain Name : wisdom
VTP Pruning Mode : Enabled
VTP V2 Mode : Disabled
VTP Traps Generation : Disabled
MD5 digest : 0xE8 0x5A 0x7D 0xB1 0x0E 0xBC 0xEB 0x1F
Configuration last modified by 0.0.0.0 at 3-1-93 02:15:51
Local updater ID is 0.0.0.0 (no valid interface found)
SW1#
創建VLAN2 VLAN3 VLAN4 VLAN5
SW1(config)#vlan 2
SW1(config-vlan)#vlan 3
SW1(config-vlan)#vlan 4
SW1(config-vlan)#vlan 5
SW1(config-vlan)#
在交換機SW1上檢查已創建的VLAN
SW1#sho vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/5, Fa0/6, Fa0/7
Fa0/8, Fa0/9, Fa0/16, Fa0/17
Fa0/18, Fa0/19, Fa0/20, Fa0/21
Fa0/22, Fa0/23, Fa0/24
2 VLAN0002 active
3 VLAN0003 active
4 VLAN0004 active
5 VLAN0005 active
SW1#show interfaces fastEthernet 0/1 switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: down
Administrative Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Administrative private-vlan trunk native VLAN: none
Administrative private-vlan trunk encapsulation: dot1q
Administrative private-vlan trunk normal VLANs: none
Administrative private-vlan trunk private VLANs: none
Operational private-vlan: none
Trunking VLANs Enabled: ALL
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
Protected: false
Appliance trust: none
配置SW2:
Switch#
Switch#config t
Enter configuration commands, one per line. End with CNTL/Z.
SW2(config)#int fastEthernet 0/1
SW2(config-if)#switchport trunk encapsulation dot1q //如果是3550端口先要封裝dot1q,因為默認為auto時不可以直接設置端口的trunk模式
SW2(config-if)#switchport mode trunk
SW2(config-if)#exit
SW2(config)#vtp domain wisdom
Changing VTP domain name from test to wisdom
SW2(config)#vtp mode client
Setting device to VTP CLIENT mode.
SW2(config)#vtp password cisco
Setting device VLAN database password to cisco
SW2(config)#
SW2#show interfaces fastEthernet 0/1 switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: down
Administrative Trunking Encapsulation: dot1q
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: none
Operational private-vlan: none
Trunking VLANs Enabled: ALL
Pruning VLANs Enabled: 2-1001
Capture Mode Disabled
Capture VLANs Allowed: ALL
Protected: false
Unknown unicast blocked: disabled
Unknown multicast blocked: disabled
Voice VLAN: none (Inactive)
SW2#
SW2#show vtp status
VTP Version : 2
Configuration Revision : 8
Maximum VLANs supported locally : 1005
Number of existing VLANs : 9
VTP Operating Mode : Client
VTP Domain Name : wisdom
VTP Pruning Mode : Enabled
VTP V2 Mode : Disabled
VTP Traps Generation : Disabled
MD5 digest : 0x84 0x50 0x9C 0xD3 0x21 0x08 0xF1 0x40
Configuration last modified by 0.0.0.0 at 3-1-93 02:29:34
SW2#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/2, Fa0/3, Fa0/4, Fa0/5
Fa0/6, Fa0/7, Fa0/8, Fa0/9
Fa0/10, Fa0/11, Fa0/12, Fa0/13
Fa0/14, Fa0/15, Fa0/16, Fa0/17
Fa0/18, Fa0/19, Fa0/20, Fa0/21
Fa0/22, Fa0/23, Fa0/24, Gi0/1
Gi0/2
2 VLAN0002 active
3 VLAN0003 active
4 VLAN0004 active
5 VLAN0005 active
SW2不用配置VLAN,同步了SW1的VLAN信息.實驗成功
8.配置生成樹(Spanning Tree)
目的:由於業務的要求,要對鏈路實現冗餘,但鏈路的冗餘有可能給網絡帶來廣播風暴,MAC地址的不穩定,環路. Spanning Tree protocol 在可以實現冗餘的同時又可以解決以上三個問題.
(CISCO的交換機默認就啟用了Spanning Tree protocol,不需配置就可以實現鏈路冗餘)
2950#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 000d.28c2.5f40
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 000d.28c2.5f40
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg FWD 19 128.1 P2p
Fa0/2 Desg FWD 19 128.2 P2p
3550#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 000d.28c2.5f40
Cost 19
Port 1 (FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 0012.43b2.fc80
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Root FWD 19 128.1 P2p
Fa0/2 Altn BLK 19 128.2 P2p
注:SW3550的F0/2已為BLK狀態.
2.用Per VLAN Spanning Tree(PVST+)實現負載均衡
目的:sw2950上的VLAN2與sw3550上的VLAN2通過紅色的鏈路通信,此時sw3550的F0/2為BLK狀態,sw2950上的VLAN3與sw3550上的VLAN3通過藍色的鏈路通信,此時sw2950的F0/1為BLK狀態,在實現鏈路冗餘的同時又實現負載均衡。用Per VLAN Spanning Tree(PVST+)技術可以達到此目的。
SW2950的配置與調試信息:
2950#show run
hostname 2950
spanning-tree mode pvst
spanning-tree vlan 2 priority 4096
spanning-tree vlan 3 priority 40960
!
!
interface FastEthernet0/1
switchport mode trunk
no ip address
spanning-tree vlan 3 cost 256
!
interface FastEthernet0/2
switchport mode trunk
no ip address
end
2950#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 000d.28c2.5f40
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 000d.28c2.5f40
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg FWD 19 128.1 P2p
Fa0/2 Desg FWD 19 128.2 P2p
VLAN0002
Spanning tree enabled protocol ieee
Root ID Priority 4098
Address 000d.28c2.5f40
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 4098 (priority 4096 sys-id-ext 2)
Address 000d.28c2.5f40
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg FWD 19 128.1 P2p
Fa0/2 Desg FWD 19 128.2 P2p
VLAN0003
Spanning tree enabled protocol ieee
Root ID Priority 32771
Address 0012.43b2.fc80
Cost 19
Port 2 (FastEthernet0/2)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 40963 (priority 40960 sys-id-ext 3)
Address 000d.28c2.5f40
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Altn BLK 256 128.1 P2p
Fa0/2 Root FWD 19 128.2 P2p
2950#
SW3550的配置與調試信息:
3550#show run
hostname 3550
!
interface FastEthernet0/1
switchport trunk encapsulation dot1q
switchport mode trunk
!
interface FastEthernet0/2
switchport trunk encapsulation dot1q
switchport mode trunk
end
3550#show sp
3550#show spanning-tree
VLAN0001
Spanning tree enabled protocol ieee
Root ID Priority 32769
Address 000d.28c2.5f40
Cost 19
Port 1 (FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 0012.43b2.fc80
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Root FWD 19 128.1 P2p
Fa0/2 Altn BLK 19 128.2 P2p
VLAN0002
Spanning tree enabled protocol ieee
Root ID Priority 4098
Address 000d.28c2.5f40
Cost 19
Port 1 (FastEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32770 (priority 32768 sys-id-ext 2)
Address 0012.43b2.fc80
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Root FWD 19 128.1 P2p
Fa0/2 Altn BLK 19 128.2 P2p
VLAN0003
Spanning tree enabled protocol ieee
Root ID Priority 32771
Address 0012.43b2.fc80
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32771 (priority 32768 sys-id-ext 3)
Address 0012.43b2.fc80
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg FWD 19 128.1 P2p
Fa0/2 Desg FWD 19 128.2 P2p
3550#
總結:通過以上的配置,當2950的VLAN2要與3550的VLAN2通信時走的是紅色的鏈路, 當2950的VLAN3要與3550的VLAN3通信時走的是藍色的鏈路,在實現在冗餘的同時又實現了負載均衡。