1、思科交换机基本配置研发七部思科交换机基本介绍思科交换机基本介绍交换机型号交换机型号Catalyst2960系列交换机Catalyst3560系列交换机Catalyst3750系列交换机Catalyst4500系列交换机Catalyst4948系列交换机Catalyst6500系列交换机3560系列交换机三层交换机三层交换机支持支持PoE(PoweroverEthernet)设备)设备支持支持IPv6汇聚层交换机汇聚层交换机中型企业中型企业Catalyst-3560G-24TS技术参数转发带宽:32Gbps每秒分组数:38.7Mpps支持的mac地址:1200
2、0支持的路由:11000千兆以太网SFP:410/100/1000端口:24不支持PoE思科交换机测试中常用配置交换机配置模式用户模式Switch特权模式SwitchenableSwitch#全局模式Switch#configureterminalSwitch(config)#每次进入交换机时,首先会进入到用户模式下每次进入交换机时,首先会进入到用户模式下,在此模式下不能对交换,在此模式下不能对交换机进行修改、甚至有些信息都无法查看,为了更进一步的对交换机进行操作,机进行修改、甚至有些信息都无法查看,为了更进一步的对交换机进行操作,我们必须进入到特权模式或全局模式,而从用户模式
3、下只能进入特权模式,我们必须进入到特权模式或全局模式,而从用户模式下只能进入特权模式,再从特权模式进入全局模式,也就是说之中不能跨级。再从特权模式进入全局模式,也就是说之中不能跨级。更改主机名更改主机名SwitchenSwitch#conftSwitch(config)#hostname12341234(config)#更改特权密码更改特权密码1234(config)#enablepassword1231234(config)#1234(config)#enablesecret2341234(config)#查看全局配置Switch#showrunning-config保存当前
4、配置Switch#copyrunning-configstartup-config恢复出厂默认Switch#erasestartup-configSwitch#reload明文密码和密文密码Password1234#showrunning-confighostname1234enablepassword123Secret1234#showrunning-confighostname1234enablesecret5$1$CCFV$0DTd3rSPZNycrVDjn1rKv/(MD5加密的字符串)enablepassword123当明文和密文同时存在时,密
5、文优先级高。当明文和密文同时存在时,密文优先级高。端口配置全局模式下进入端口后,可以对端口进行配置。Switch#conftSwitch(config)#interfacegigabitEthernet0/1Switch(config-if)#批量修改端口range命令端口速率:Switch(config-if)#speed10Force10Mbpsoperation100Force100Mbpsoperation1000Force1000MbpsoperationautoEnableAUTOspeedconfigurationSwitch(
6、config-if)#speedautoSwitch(config-if)#双工模式:Switch(config-if)#duplexautoEnableAUTOduplexconfigurationfullForcefullduplexoperationhalfForcehalf-duplexoperationSwitch(config-if)#duplexautoSwitch(config-if)#端口描述Switch(config-if)#descriptionvlan10trunkSwitch(config-if)#Vlan设置Vlan设置范
7、围:1-4094在全局模式下配置vlanSwitch#conftSwitch(config)#vlan10Switch(config-vlan)#namevlan10Switch(config-vlan)#vlan20Switch(config-vlan)#namevlan20Vlan名称可以自行定义Switch#showvlan查看vlan配置信息vlan10配置192.168.10.1/24的ip地址Switch#conftSwitch(config)#vlan10Switch(config-vlan)#namevlan10Switch(config-vlan)#exi
8、tSwitch(config)#interfacevlan10Switch(config-if)#ipaddress192.168.10.1255.255.255.0Switch(config-if)#endSwitch#copyrunning-configstartup-config配置ip地址的命令格式:ipaddressip-addressnetmask测试常用端口类型Access/trunk将此端口设置为vlan10的access口Switch(config-if)#switchportmodeaccessSwitch(config-if)#swit
9、chportaccessvlan10Switch(config-if)#将此端口设置为vlan10的trunk口Switch(config-if)#switchporttrunkencapsulationdot1qSwitch(config-if)#switchportmodetrunkSwitch(config-if)#switchporttrunkallowedvlan10当一个端口允许多个vlan通过时,trunkallowedvlan中要添加各条vlan信息Switch(config-if)#switchporttrunkencapsulation
10、dot1qSwitch(config-if)#switchportmodetrunkSwitch(config-if)#switchporttrunkallowedvlanallSwitch(config-if)#switchporttrunkallowedvlan10,50,60Switch(config-if)#switchporttrunkallowedvlanadd20(remove删除)Switch(config-if)#switchporttrunkallowedvlanadd30Switch(config-if)#switchpo
11、rttrunkallowedvlanadd40Switch(config-if)#switchporttrunknativevlan1Switch(config-if)#noshutdownSwitch(config-if)#endSwitch#copyrunning-configstartup-config此端口为vlan10vlan20vlan30vlan40的trunk口,defaultvlan1经过此端口时不会带上标签。光端口配置Switch(config)#interfacegigabitEthernet0/25Switch(config-if
12、)#switchportmodeaccessSwitch(config-if)#switchportaccessvlan10Switch(config-if)#noshutdownSwitch(config-if)#endSwitch#copyrunning-configstartup-config注意:由于思科的交换机只自动识别自己品牌的光模块,所以如果用其他品牌的光模块,需在配置模式下输入一下两条命令,开启兼容性。serviceunsupported-transceivernoerrdisabledetectcausegbic-invalid命令输入完成后保
13、存设置重启设备端口镜像配置Cisco3560G配置全局配置下:Switch(config)#monitorsession1destinationinterfacegigabitEthernet0/1Switch(config)#monitorsession1sourceinterfacegigabitEthernet0/2bothSwitch(config)#monitorsession1sourceinterfacegigabitEthernet0/3bothmonitorsession1建立一个端口镜像组Destination监控端口
14、Source镜像端口DHCP配置配置一个dhcp给vlan10内的主机分配地址Switch(config)#servicedhcpSwitch(config)#ipdhcppoolvlan10Switch(dhcp-config)#network192.168.10.0255.255.255.0Switch(dhcp-config)#default-router192.168.10.1Switch(dhcp-config)#dns-server192.168.10.2Switch(dhcp-config)#lease32020(天/小时/分钟)(缺省为1天)Swi
15、tch(dhcp-config)#exitSwitch(config)#ipdhcpexcluded-address192.168.10.1192.168.10.19Switch(config)#ipdhcpexcluded-address排除某些地址,禁止被动态分配DHCP设置是针对全局的,不是定义在某个接口上的。DHCP调试命令Switch(config)#noservicedhcp关闭dhcp服务Switch#showipdhcpbinding查看dhcp分配情况思科作思科作DHCPserver给给AP分地址分地址在server中设置Option43、Opt
16、ion60字段信息。Switch(config)#ipdhcppoolvlan20Switch(dhcp-config)#network192.168.1.0255.255.255.0Switch(dhcp-config)#default-router192.168.1.1Switch(dhcp-config)#option43hex01060104c0a801e4Switch(dhcp-config)#option60hexxxxxxxxxxxxx(AC回的offer包中的信息)Switch(dhcp-config)#lease1Switch(dhcp
17、-config)#endSwitch#copyrunning-configstartup-configDHCPrelay配置DHCPrelay功能可以汇聚处于不同广播域的客户端的DHCP请求,转发给DHCP服务器,并发送DHCP服务器的响应给各个客户端,也就是起到了DHCP报文在各个网段的转发功能。Cisco的设备需要启用iphelper-address命令,来实现此功能。配置了iphelper-address命令之后的交换机在中继DHCP请求时的工作过程如下:(1)DHCP客户端发送请求,由于没有IP地址,所以自己的源IP地址为0.0.0.0,而且也不知道目的DHCP服务器的地址
18、,所以广播255.255.255.255。该数据报文中还包括源mac地址和目的mac地址(全F)。(2)当交换机接收到该数据包的时候,它就用自己的接口地址来取代源地址0.0.0.0,并且用iphelper-address命令置顶的地址来取代目的地址255.255.255.255。(3)当DHCP服务器接收到交换机转发过来的DHCP请求包时,它会做出响应,并且由交换机把数据包转发回客户端。DHCPrelay配置Switch(config)#vlan100Switch(config-vlan)#namevlan100Switch(config-vlan)#intvlan100Swi
19、tch(config-if)#iphelper-address192.168.1.228Switch(config-if)#exitSwitch(config)#servicedhcpSwitch(config)#ipdhcprelayinformationtrust-allSwitch(config)#endSwitch#copyrunning-configstartup-configDHCPrelay功能测试实例:AClan端口开启dhcpserverdhcpserver1:192.168.20.10-192.168.20.100/24的地址,网关为192.1
20、68.20.1。dhcpserver2:192.168.30.10-192.168.30.100/24的地址,网关为192.168.30.1。AClan端口地址为192.168.1.228正确配置交换机和AC使AP获得相应地址并上线。AClan3560GAP1AP2Vlan30Vlan20Vlan10Cisco3560G配置interfaceGigabitEthernet0/1interfaceVlan10switchportaccessvlan10ipaddress192.168.1.1255.255.255.0switchportmodeaccess!int
21、erfaceGigabitEthernet0/2interfaceVlan20switchportaccessvlan20ipaddress192.168.20.1255.255.255.0switchportmodeaccessiphelper-address192.168.1.228!interfaceGigabitEthernet0/3interfaceVlan30switchportaccessvlan30ipaddress192.168.30.1255.255.255.0switchportmodeaccessiphe
22、lper-address192.168.1.228iproutingservicedhcpipdhcprelayinformationtrust-allAC配置瘦AP端口地址:192.168.1.228255.255.255.0瘦AP端口DHCP:dhcpserver1:192.168.20.10-192.168.20.100/24的地址,网关为192.168.20.1。dhcpserver2:192.168.30.10-192.168.30.100/24的地址,网关为192.168.30.1。静态路由:目的地址0.0.0.0子网掩码0.0.0.0下一跳1
23、92.168.1.1静态路由设置Switch(config)#iprouting(全局路由)思科默认不开启Switch(config)#iproute192.168.2.0255.255.255.0192.168.1.1(静态路由格式:目的地址子网掩码下一跳)静态路由测试实例3560GPCACStaAPVlan2Vlan1Vlan3Vlan2AP通过dhcp方式上线,集中转发正常广播SSIDAC开启2个虚接口,STA连接vif1,Vif1属于vlan1地址192.168.10.1/24,vif2属于vlan2地址192.168.20.1/243560G1端口与A
24、C的vif2相连,地址为192.168.20.2/243560G2端口与PC相连,地址为192.168.30.1/24PC的地址为192.168.30.1/24网关为192.168.30.1测试要求:STA正常获得地址并且与PC通信。Cisco3560G配置interfaceVlan20ipaddress192.168.20.2255.255.255.0interfaceVlan30ipaddress192.168.30.1255.255.255.0iproute192.168.10.0255.255.255.0192.168.20.1iproutingint
25、erfaceGigabitEthernet0/1switchportaccessvlan20switchportmodeaccessinterfaceGigabitEthernet0/2switchportaccessvlan30switchportmodeaccessAC开启2个虚接口vif1、vif2,vif1开启dhcpserver功能,给STA分配地址,同时将vif1的地址设置为网关。同时配置静态路由目的地址192.168.30.0子网掩码255.255.255.0下一跳:192.168.20.2测试实例三层漫游在三层交换机上划分三个VLAN,VLAN10VLAN20VLAN30,其管理地址分别为192.168.1