以太网交换机
v 交换机是用来连接局域网的主要设备
▪ 交换机能够根据以太网帧中目标地址智能的转发数据,因此交换机工作在数据链路层
▪ 交换机分割冲突域,实现全双工通信
交换机的配置模式
v 用户模式:Switch>
v 特权模式:Switch>enable
Switch#
v 全局配置模式:Switch#config terminal
Switch(config)#
v 接口配置模式:Switch(config)#interface fa0/1
Switch(config-if)#
v Line模式:Switch(config)#line console 0
Switch(config-line)#
配置主机名
v Switch>en
v Switch#conf t
v Switch(config)# hostname Benet-sw1
v Benet-sw1(config)#
查看交换机的配置
v Benet-sw1(config)# show running-config
version 12.1
no service pad
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname Benet-sw1
配置enable明文口令
v Benet-sw1(config)#enable password cisco
v Benet-sw1(config)#exit
v Benet-sw1#show running-config
version 12.1
no service pad
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname Benet-sw1
!
enable password cisco
!
ip subnet-zero
!
检验enable口令的作用
v Benet-sw1# exit
Press RETURN to get started.
v Benet-sw1>enable
Password:cisco
v Benet-sw1#
配置enable加密口令
v Benet-sw1(config)# enable secret ciscolab
v Benet-sw1#show running-config
version 12.1
no service pad
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname Benet-sw1
!
enable secret 5 $1$e1k3$tmDh/6EG9c5enGXDjjj7j/
enable password cisco
!
检验enable加密口令的作用
v Benet-sw1# exit
Press RETURN to get started.
v Benet-sw1>enable
Password:ciscolab
v Benet-sw1#
配置Console口令
v Benet-sw1(config)#line console 0
v Benet-sw1(config-line)#password 123
v Benet-sw1(config-line)#login
v Benet-sw1#show run
interface Vlan1
no ip address
no ip route-cache
shutdown
!
ip http server
!
line con 0
password 123
login
登录口令的输入
Switch con0 is now available
Press RETURN to get started.
User Access Verification
Password:123
Switch>en
Password:ciscolab
Switch#
配置管理用IP地址与网关
v Benet-sw1(config)# interface vlan 1
v Benet-sw1(config-if)# ip address 192.168.1.1 255.255.255.0
v Benet-sw1(config-if)# no shutdown
v Benet-sw1# show running-config
!
interface FastEthernet0/24
no ip address
!
interface Vlan1
ip address 192.168.1.1 255.255.255.0
no ip route-cache
!
ip http server
Benet-sw1(config)#ip default-gateway 192.168.1.100
查看MAC地址表
v Benet-sw1#show mac-address-table
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
All 000d.28be.b640 STATIC CPU
All 0100.0ccc.cccc STATIC CPU
All 0100.0ccc.cccd STATIC CPU
All 0100.0cdd.dddd STATIC CPU
1 0013.8044.ff40 DYNAMIC Fa0/2
1 0013.8044.ff41 DYNAMIC Fa0/8
Total Mac Addresses for this criterion: 6
使用CDP协议
v Benet-sw1#show cdp ?
entry Information for specific neighbor entry
interface CDP interface status and configuration
neighbors CDP neighbor entries
traffic CDP statistics
| Output modifiers
v Benet-sw1#show cdp neighbor
Capability Codes: R - Router, T - TransBridge, B - SourceRouteBridge
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID Local Intrfce Holdtme Capability Platform Port ID
R1 Fas 0/19 139 R 2621XM Fas 0/0
v Benet-sw1#show cdp neighbors detail
-------------------------
Device ID: R1
Entry address(es):
IP address: 192.168.1.1
Platform: cisco 2621XM, Capabilities: Router
Interface: FastEthernet0/19, Port ID (outgoing port): FastEthernet0/0
Holdtime : 143 sec
Version :
Cisco Internetwork Operating System Software
IOS (tm) C2600 Software (C2600-IS-M), Version 12.2(21), RELEASE SOFTWARE (fc3)
Copyright (c) 1986-2003 by cisco Systems, Inc.
Compiled Tue 02-Dec-03 16:06 by kellmill
advertisement version: 2
Duplex: full
保存交换机的配置
v Benet-sw1# copy running-config startup-config
或
v Benet-sw1# write
Building configuration...
[OK]
恢复设备出厂默认值
v Benet-sw1# erase startup-config
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Erase of nvram: complete
v Benet-sw1#reload
Proceed with reload? [confirm]
VLAN概述
v 什么是VLAN
§ Virtual LAN(虚拟局域网)是物理设备上连接的不受物理位置限制的用户的一个逻辑组。
v 为什么引入VLAN
§ 交换机分割了冲突域,但是不能分割广播域
§ 随着交换机端口数量的增多,网络中广播增多,降低了网络的效率
§ 为了分割广播域,引入了VLAN
v VLAN的作用
§ 广播控制
§ 安全性
§ 带宽利用
§ 延迟
v VLAN的种类
§ 基于端口划分的静态VLAN
§ 基于MAC地址划分的动态VLAN
Cisco交换机上静态VLAN的配置
v 配置VLAN的步骤
§ 创建VLAN
§ 将端口加入到相应的VLAN中
§ 验证
v 创建VLAN有以下2种方法
§ 在全局配置模式下创建VLAN
§ 进入VLAN数据库中创建VLAN
全局配置模式下创建VLAN
v Switch(config)#vlan vlan-id
v Switch(config-vlan)#name vlan-name
进入VLAN 数据库创建VLAN
v Switch#vlan database
v Switch(vlan)#vlan 2
VLAN 2 added:
Name: VLAN0002
v Switch(vlan)#exit
APPLY completed.
Exiting....
删除已创建的VLAN
v Switch#vlan database
v Switch(vlan)#no vlan 2
Deleting VLAN 2...
或:
v Switch(config)#no vlan 2
将端口加入VLAN
v Switch(config)# interface f0/1
v Switch(config-if)# switchport access vlan vlan-id
v Switch(config-if)# no switchport access vlan vlan-id
也可以同时将多个端口添加到某个VLAN中:Switch(config)# interface range f0/1 – 10
Switch(config-if-range)# switchport access vlan vlan-id
验证VLAN的配置
v Switch# show vlan brief
v Switch# show vlan id vlan-id
VLAN配置实例
Switch#vlan database
Switch(vlan)#vlan 2 name v2
VLAN 2 added:
Name: v2
Switch(vlan)#exit
APPLY completed.
Exiting....
Switch#config terminal
Switch(config)#interface range f0/5 - 10
Switch(config-if-range)#switchport access vlan 2
查看VLAN配置
v Switch#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
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
2 v2 active Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
其他常用命令
v 其他常用命令
§ 指定/删除VLAN描述字符
• description string
• no description
§ 查看VLAN设置
• show vlan [vlan_id ]
§ 开启/关闭VLAN接口
• shutdown
• no shutdown
•
?的使用
v Switch# ?
Exec commands:
access-enable Create a temporary Access-List entry
access-template Create a temporary Access-List entry
archive manage archive files
cd Change current directory
clear Reset functions
clock Manage the system clock
cns CNS subsystem
configure Enter configuration mode
connect Open a terminal connection
copy Copy from one file to another
debug Debugging functions (see also 'undebug')
delete Delete a file
dir List files on a filesystem
disable Turn off privileged commands
disconnect Disconnect an existing network connection
dot1x IEEE 802.1X commands
enable Turn on privileged commands
v Switch(config)#s?
scheduler service shutdown snmp snmp-server
spanning-tree stackmaker system
v Switch(config)#spanning-tree ?
backbonefast Enable BackboneFast Feature
etherchannel Spanning tree etherchannel specific configuration
extend Spanning Tree 802.1t extensions
loopguard Spanning tree loopguard options
mode Spanning tree operating mode
pathcost Spanning tree pathcost options
portfast Spanning tree portfast options
uplinkfast Enable UplinkFast Feature
vlan VLAN Switch Spanning Tree
Tab键的使用
v Switch(config)#ena
v Switch(config)#enable
使用命令简写
v Switch>en
v Switch#conf t
v Switch(config)#ena pass 123
使用缓存命令
v 使用向上箭头,出现上一次执行的命令
v Switch# show history
阶段总结:
î 划分VLAN的作用
ø 控制广播
ø 安全性
î VLAN的种类
ø 静态VLAN-基于端口划分的
ø 动态VLAN-基于MAC地址
î VLAN的配置
ø 添加VLAN、删除VLAN
ø 将端口加入VLAN
ø 查看VLAN的配置
ISL和802.1Q 的异同
v 相同点
§ 都是显式标记,即帧被显式标记了VLAN的信息
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9650775/viewspace-923197/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9650775/viewspace-923197/
本文介绍以太网交换机的基本配置流程,包括配置模式、主机名、口令及IP地址等。并详细讲解VLAN的概念、作用及配置方法,帮助读者掌握交换机的基础配置技能。
1599

被折叠的 条评论
为什么被折叠?



