资源预览内容
第1页 / 共20页
第2页 / 共20页
第3页 / 共20页
第4页 / 共20页
第5页 / 共20页
第6页 / 共20页
第7页 / 共20页
第8页 / 共20页
第9页 / 共20页
第10页 / 共20页
亲,该文档总共20页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
交换机部分命令交换机部分命令一、交换机模式切换Swithenable /切换到特权Swith#config t /切换到全局配置模式Swith(config)# interface f0/1 /进入接口f0/0Swith(config)# interface vlan 1 /进入VLAN 1中Swith(config-if)#ip address 192.168.1.1 255.255.255.0 /对VLAN1设置IP地址和子网掩码Swith(config-if)#no shutdown /激活VLAN1二、设置交换机的密码1、用户到特权的密码Swith(config)#enable password 123 (优先级低)Swith(config)#enable secret 456 (优先级高) /如果两个都设置则456生效2、控制台console密码设置Swith(config)# line con 0 Swith(config-line)#login Swith(config-line)#password console123 /设置console密码为telnet1233、启用telnet密码Swith(config)#line vty 0 15 /最多有015人可以telnet访问swith,合计16人Swith(config-line)#login Swith(config-line)#password telnet123 /设置telnet密码为telnet123注:要想真正生效telnet还要设置特权密码三、交换机命名hostname BENETSW01Swith(config)#hostname BENETSW01 /使用hostname命名交换机的名字四、show命令集Swith#show version /显示IOS版本信息Swith#show int vlan 1 brief /简单的显示VLAN1的信息Swith#show running-config /显示正在运行的配置文件Swith#show startup-config /显示己经保存的配置文件Swith#show mac-address-table /显示MAC地址表Swith#show mac-address-table /显示MAC地址表更新的间隔,默认为5分钟Swith#show neighbor detail /显示邻居详细信息Swith#show traffic /显示CDP流量Swith#show 五、设置交换机的网关和DNS名称服务器的IP地址Swith(config)# ip default-gateway 192.168.10.8 /交换机的网关设置为192.168.10.8Swith(config)#ip domain -name server 202.106.0.20 /设置DNS名称服务器地址Swith(config)# no ip domain-lookup /交换机名称服务器的域名查询六、创建、删除、查看VLANSwitch#vlan database /进入vlan数据库配置模式Switch(vlan)#vlan 2 /创建VLAN2自动命名为vlan0002,同vlan2 name salesVLAN 2 added: Name: VLAN0002 Switch(vlan)#exit /退出时应用生效Swith(vlan)#no vlan 2 /删除vlan2Switch(config)# interface f0/1Switch(config-if)# switchport access vlan 2 /将端口加入vlan 2中Switch(config-if)# no switchport access vlan 2 /将端口从vlan2中删除Switch(config)# interface range f0/1 10 / 进行F0/1到10端口范围Switch(config-if-range)# switchport access vlan 2 /将f0/1到f0/10之间的所有端口加入vlan 2Switch# show vlan brief /查看所有VLAN的摘要信息Switch# show vlan id (vlan-id ) /查看指定VLAN的信息七、开启并查看trunk端Swith(config)#interface f0/24 Swith(config-if)#swith mode trunk /将f0/24端口设置为trunkSwitch#show interface f0/24 switchport /查看f0/24的接口状态八、从Trunk中添加、删除VlanSwitch (config-if )# switchport trunk allowed vlan remove 3 /从trunk端口删除v lan3通过Switch (config-if)# switchport trunk allowed vlan add 3 /从trunk端口添加vlan3通过Switch # show interface interface-id switchport /检查中继端口允许VLAN的列表九、单臂路由配置Router(config)# interface f0/0.1 Router(config-subif)# encapsolution dot1q 1 /子接口封装dot1q 针对的是VLAN1Router(config-subif)# ip address 192.168.1.1 255.255.255.0 /设置VLAN的网关地址Router(config)# interface f0/0.2 Router(config-subif)# encapsolution dot1q 2 /子接口封装dot1q针对的是vlan2Router(config-subif)# ip address 192.168.2.1 255.255.255.0 /设置vlan2的网关的地址十、配置VTP服务器S1#vlan database /进入vlan配置模式S1(vlan)#vtp server /设置该交换机为VTP服务器模式,考试时选默认是透明模式,但思科是默认为服务器模式。S1(vlan)#vtp domain domain-name /设置VTP管理域名称S1(vlan)#vtp pruning /启用VTP修剪功能S1(vlan)#exitS1#show vtp status /显示VTP状态信息十一、配置VTP客户端S2#vlan databaseS2(vlan)#vtp client /设置该交换机为VTP客户端模式S2(vlan)#vtp domain domain-name /这里域名必须和上面的vtp服务器设置的domain名称一样S2(vlan)#exit十二、交换机基本配置-mac地址配置Switch(config)#mac-address-table aging-time 100 /设置学习的MAC地址的超时时间,默认300sSwitch(config)#mac-address-table permanent 0050.8DCB.FBD1 f0/3 /添加永久地址Switch(config)#mac-address-table resticted static 0050.8DCB.FBD2 f0/6 f0/7 /加入限制性静态地址,它是在设置永久性地址的基础上,同时限制了源端口,它只允许所static配置的接口(f0/6)与指定的端口(f0/7)通信,提高安全性。Switch(config)#endSwitch#show mac-address-table (查看MAC地址表)Switch#clear mac-address-table dynamic (清除动态学习的MAC地址表项)Switch#clear mac-address-table resticted static (清除配置的限制性MAC地址表项)十三、生成树快速端口(PortFast)配置STP PortFast是一个Catalyst的一个特性。在STP中,只有forwarding状态,port才能发送用户数据。如果一个port一开始是没有接pc,一旦pc接上,就会经历blocking(20s)-listening(15s)-learing(15s)-forwarding状态的变化。这样从pc接上网线,到能发送用户数据,缺省的配置下需要等50秒的时间,但如果设置了portfast,就使得该端口不再应用STP算法,一旦该端口物理上能工作,就立即将其置为“转发”状态。在基于IOS交换机上,PortFast只能用于连接到终端设备的接入层交换机端口上。开启PortFast命令:Switch(config)#interface f0/1Switch(config-if)#spanning-tree portfast如果把批次开启可以用:Switch(config)#interface range f0/1 3Switch(config-if-range)#spanning-tree portfast /注:只有在确认不会产生环路的端口上开启快速端口。十四、STP的负载均衡配置1、使用、使用STP端口权值(优先级)实现负载均衡端口权值(优先级)实现负载均衡当交换机的两个口形成环路时,STP端口优先级用来决定那个口是转发状态,那个处于阻塞的。可以通过修改Vlan对应端口的优先级来决定该VLAN的流量走两对Trunk链路中那一条。如上图,我们用端口F0/23做Trunk1,用f0/24做Trunk2。具体配置如下:、配置、配置VTP、VLAN及及Trunk(和上面(和上面VLAN配置过程一样,我们把配置过程一样,我们把S1设成服务器模式,设成服务器模式,S2设设为客户端模式)为客户端模式)(配置vtp-在S1、S2上)S1#vlan database /进入VLAN配置子模式S1(vlan)#vtp server S1(vlan)#vtp domain vtpserver /这三步也要在S2上执行,只是把第二步的Vtp server 换成vtp client(配置Trunk-在S1、S2上)S1(config)#interface f0/23S1(config-if)#switchport mode trunkS1(config-if)#exitS1(config)#interface f0/24S1(config-if)#switchport mode trunk /在S2上执行同样的这几步操作。(配置VLAN-只在S1上)S1#vlan databaseS1(vlan)#vlan 2 name vlan2 S1(vlan)#vlan 3 name vlan3 /依次创建2-5 vlan。S1
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号