CCNP交换机部分的学习笔记
本帖最后由 miucat 于 2023-9-23 23:54 编辑由于系统文章大小限制,未能加图,请大家直接下载原文附件。
========================================
1. 以太网1. 接口MTU和ip MTURouter(config-if)#mtu 1500Router(config-if)#ip mtu 1500Router#sh int s1/0Router#sh ip int s1/02. 管理MAC表 48位,点分十六进制表示Switch#show mac address-tableSwitch#clear mac address-tableSwitch(config)#mac address-table static aaaa.bbbb.cccc vlan 10interface e0/02. 二层交换1. ProtectedportSwitch(config-if)#switchportprotected2. Native VlanSwitch(config-if)#switchport trunk native vlan 10Switch(config)#vlan dot1q tag native配置对native vlan也打标签
Vlan范围:(dot1q)
3. Trunk配置ISL:支持1-1005个vlan编号DOT1Q:支持1-4094个vlan编号Switch(config-if)#switchport mode access将接口设置为access模式Switch(config-if)#switchporttrunk encapsulation {dot1q | ISL | negotiate } Switch(config-if)#switchportmode trunkSwitch#showinterface f0/8 switchport将接口设置为DTP动态协商,可auto或desirableSwitch(config-if)#switchport nonegotiate将接口设置为nonegotiate,不发送DTP帧,如果配置为非协商,那么必须手工配置接口模式为access或trunkSwitch(config-if)#switchportmode dynamic 配置接口为协商模式Switch#showinterface trunk 查看接口trunk/vlan/private-vlan信息Switch#showinterfaces fa0/0 switchport 查看接口二层trunk信息Switch(config-if)#switchporttrunk allowed vlan {WORD | add | all | except | none | remove}Switch1(config-if)#switchporttrunk allowed vlan ? WORD VLAN IDs of the allowedVLANs when this port is in trunking mode add add VLANs tothe current list all all VLANs exceptall VLANsexcept the following none no VLANs removeremove VLANs from the current listSwitch(config-if)#switchporttrunk allowed vlan remove 20
4. VTP1. VTP配置Switch1(config)#vtp domain ciscoSwitch1(config)#vtp mode {server | client|transparent}Switch1(config)#vtp password 123456Switch1#sh vtp password2. 查看VTP状态Switch1#sh vtp status3. 查看trunk及allowed vlan状态Switch1#shint trunk4. VTPpruning 开启VTP修剪Switch2(config)#vtp pruning5. 私有VLAN(PVLAN)1. 创建主VLAN:Vlan 100 Private-vlan primary2. 创建辅助VLANVlan 101 Private-vlan communityVlan 102 Private-vlan ioslate3. 配置主VLAN,将二层辅助VLAN关联到主VLANVlan 100 Private-vlan association 101,1024. 将辅助VLAN映射到主VLAN的SVI接口,从而允许PVLAN入口流量的三层交换。Interface vlan100 Private-vlan mapping add 101,1025. 配置接口Interface f0/1 Switchport mode private-vlan host Switchport private-vlan host-association 100101 //关联主VLAN和辅助VLAN到接口Interface f0/2 Switchport mode private-vlan host Switchport mode private-vlanhost-association 100 102主机接口配置Interface f0/3 Switchport mode private-vlan promiscuous Switchport private-vlan mapping add 100 101//将端口映射到PLAN 混杂端口配置6. 查看及验证Show pvlanmapping PLAN配置示例 Sw(config)#vtp mode transparent Sw(config)#vlan 201 Sw(config-vlan)#private-vlanisolated Sw(config)#vlan 202 Sw(config-vlan)#private-vlancommunity Sw(config)#vlan 100 Sw(config-vlan)#private-vlanprimary Sw(config-vlan)#private-vlanassociation 201,202 ! Sw(config)#interface fa0/24 Sw(config-if)#switchport modeprivate-vlan promiscuous Sw(config-if)#switchportprivate-vlan mapping 100 201,202 Sw(config)#interface range fa 0/1- 2Sw(config-if)#switchportmode private-vlan hostSw(config-if)#switchportprivate-vlan host-association 100 202Sw(config)#interface rangefa 0/3 - 4Sw(config-if)#switchportmode private-vlan hostSw(config-if)#switchportprivate-vlan host-association 100 2013. Spanning-tree
1. 802.1D1. 每个广播域选择一个根桥桥优先级小的,然后桥MAC地址小的,当选根桥。桥ID由桥优先级和桥MAC地址组成。根桥是可以抢占的2. 每个非根桥上选择一个根端口到根桥的最低Cost最低的发送者的桥ID(先比桥优先级小的,再比桥MAC地址小的)最低的发送者端口ID(先比端口优先级小的,再比端口编号小的)
3. 每个段选择一个指定端口4. 阻塞非指定端口Switch#sh int | inbia //可以查看交换机桥MAC和接口MACSwitch#shspanning-tree//可以查看spanning-tree信息,桥优先级、接口优先级等Switch(config-if)#spanning-treecost 100000 //设置接口开销costSwitch#shspanning-tree int e0/1 //查看特定接口spanning-tree信息Switch(config-if)#bandwidth100000 //设置接口带宽Switch(config-if)#spanning-treevlan 1 port-priority 64 //设置接口优先级Switch(config)#spanning-treevlan 1 priority 4096 //设置桥优先级 portfast特性Switch(config)#spanning-treeportfast default //将所有非trunk接口激活portfast特性Switch(config-if)#spanning-treeportfast //将特定接口激活portfast特性Switch(config-if)#switchporthost //宏命令,指定接口mode为access并开启portfast特性bpduguard特性Switch(config)#spanning-treeportfast bpduguard default //为所有激活了portfast的接口激活bpduguardSwitch(config-if)#spanning-treebpduguard enable //在特定接口激活bpduguard特性 Bpdufilter特性Switch(config)#spanning-treeportfast bpdufilter defaultSwitch(config-if)#spanning-treebpdufilter enable Uplinkfast特性(强烈建议在末梢交换设备配置)Switch(config)#spanning-treeuplinkfastSwitch#showspanning-tree uplinkfast Switch(config)#spanning-treeuplinkfast max-update-rate 200 //配置uplinkfast特性的交换机每秒钟发uplink更新包的频率 backboneFast特性 Switch(config)#spanning-treebackbonefast //生成树交换机都要配 RootGuard特性Switch(config-if)#spanning-treeguard root //外部交换机接入的接口要配Switch#showspanning-tree inconsistentports//inconsistent基于vlan Loopguard特性Switch(config)#spanning-treeloopguard default//和线路单向不通有关的配置Switch(config-if)#spanning-treeguard loop UDLD特性 Switch(config)#udldenable {enable | aggressive} //光纤接口上激活UDLD Switch(config-if)#udldport //特定接口上激活UDLD 相关命令 Switch(config)#errdisable recovery? Switch(config)#errdisablerecovery interval 100 //修改errdisable的时间间隔 Switch#show errdisable recovery2. Pvst+Switch#shspanning-tree //查看spanning-tree状态信息Switch(config)#spanning-treevlan 10//针对vlan10开启spanning-tree(默认pvst+) Switch(config)#nospanning-tree vlan 10Switch(config)#spanning-treemode {mst | pvst | rapid-pvst} //设置spanning-tree模式,默认pvst+Switch(config)#spanning-treevlan 10 priority 4096 //设置[针对vlan10]的spanning-tree优先级Switch(config)#spanning-treevlan 10 root primary //宏命令,[针对vlan10]设置主根桥Switch(config)#spanning-treevlan 10 root secondary //宏命令,[针对vlan10]设置副根桥Switch(config-if)#spanning-treevlan 10 cost 15 //[针对vlan10]修改costSwitch(config-if)#spanning-treevlan 10 port-priority 64 //[针对vlan10]修改接口优先级Switch(config)#spanning-treevlan 10 hello-time 3Switch(config)#spanning-treevlan 10 forward-time 10Switch(config)#spanning-treevlan 10 max-age 30Switch#debugspanning-tree eventSwitch(config-if)#spanning-treelink-type {point-to-point | shared}
3. RSTP(802.1W),思科是per-vlan rstpSwitch(config)#spanning-treemode rapid-pvst其他命令同pvst+4. Mstp(802.1S)
Switch(config)#spanning-treemode mst //设置spanning-tree模式Switch(config)#spanning-treemst configuration //进入mst配置模式Switch(config-mst)#nameMIUCAT //修改mst域名Switch(config-mst)#revision1 //设置mst版本Switch(config-mst)#instance123 vlan 10,20,30 //划分mst实例Switch(config-mst)#instance456 vlan 40,50,60 //划分mst实例Switch(config-mst)#spanning-treemst 123 root primary //按实例配置mst主根桥Switch(config-mst)#spanning-treemst 456 root secondary //按实例配置mst次根桥
Switch(config-mst)#Shprocess cpu//查看cpu使用率,高了有环路。4. 三层交换1. VLAN间路由1. 单臂路由
R1(config)#Interfacef0/0R1(config-if)#NoshutdownR1(config)#Interfacef0/0.10R1(config-if)#Encapsulationdot1Q 10R1(config-if)#Ipadd 192.168.10.254 255.255.255.0R1(config-if)#NoshutdownR1(config)#Interfacef0/0.20R1(config-if)#Encapsulationdot1Q 20R1(config-if)#Ipadd 192.168.20.254 255.255.255.0R1(config-if)#Noshutdown2. 三层交换机基本配置Switch(config)# iprouting //开启三层交换机的路由功能Switch(config)# vlan10Switch(config-vlan)# nameClassroom //创建VLANSwitch(config)# interfacevlan 10Switch(config-if)# ipaddress 192.168.10.254 255.255.255.0Switch(config-if)# noshutdown//配置VLAN对应的SVI接口Switch(config)# interfacefast 0/1Switch(config-if)# noswitchportSwitch(config-if)# ipaddress 192.168.255.1 255.255.255.0Switch(config-if)# noshutdown//配置no switchport(routed port)三层接口Switch(config)# iproute 0.0.0.0 0.0.0.0 192.168.255.2//配置静态路由3. 三层交换机Vlan间互访及访问路由
4. 二层交换机管理vlan
5. 三层交换机环境下的管理VLAN
1. 接入交换机的配置:Switch(config)# vlan10Switch(config)# vlan20Switch(config)# vlan255Switch(config)# interfacefast0/1Switch(config-if)# switchportaccess vlan 10Switch(config)# interfacefast0/2Switch(config-if)# switchportaccess vlan 20Switch(config)# interfacefast0/15Switch(config-if)# switchingSwitch(config-if)# switchportmode trunkSwitch(config)# interfacevlan 255Switch(config-if)# ipaddress 192.168.255.1 255.255.255.0Switch(config)# ipdefault-gateway 192.168.255.254 !!为接入交换机自身设置的网关2. 核心交换机的配置:Switch(config)#vlan 10Switch(config)# vlan20Switch(config)# vlan255Switch(config)# interfacefast0/15Switch(config-if)# switchportmode trunkSwitch(config)# interfacevlan 10Switch(config-if)# ipaddress 192.168.10.254 255.255.255.0Switch(config)#interface vlan 20Switch(config-if)# ipaddress 192.168.20.254 255.255.255.0Switch(config)#interface vlan 255Switch(config-if)# ipaddress 192.168.255.254 255.255.255.05. DHCP1. 基本配置Router(config)#serviceDHCP//开启DHCP服务。Router(config)#ipdhcp pool //定义DHCP地址池,一个网段对应一个地址池Router(config-dhcp)#network//定义地址池关联的网段Router(config-dhcp)#default-router//定义分配给客户端的网关IPRouter(config)#ipdhcp excluded-address 172.16.1.100 172.16.1.103//将一个或多个地址排除在地址池之外(如网关IP等),以避免分配给客户端2. 查看及验证Router#show ip dhcpdatabase//显示 DHCP 数据库上最近的活动Router#show ip dhcpserver statistics//显示dhcp状态信息,显示dhcp发送的和接收的信息列表Router#show ip routedhcp//显示被Dhcp添加到路由表中的路由信息Router#show ip dhcpbinding//显示DHCP绑定信息3. 配置示例1. 基础实验
2. DHCP中继实验
Router(config-if)#ip helper-address192.168.200.200 1. Iphelper-address命令是配置在收到client发出的广播discovery报文的那个三层接口上,或者说,是“阻挡”这个广播DHCP报文的接口上的,例如,如果是三层交换机用access接口连接PC,那么就应该配置在该VLAN的SVI接口上。 2. Iphelper-address命令只需配置在第一个收到client发出的广播discovery报文的那个三层接口上,在此之后这些广播的DHCP报文将被中继成单播包,就是走IP路由了。 3. 注意中继设备需开启DHCP服务: service dhcp 4.注意DHCPserver与中继接口之间必须三层能通,因为中继后的单播包,源地址是配置ip helper-address的那个中继接口,所以DHCPserver在回包的时候,报文的目的IP就是这个配置ip helper-address的接口的接口IP。3. DHCP静态地址绑定1. 用client-identifier绑定Router(config)#ip dhcppool BINDRouter(config-dhcp)#host192.168.1.111 255.255.255.0Router(config-dhcp)#client-identifier unique-identifier //可以在服务器上通过show ipdhcp bingding抓取客户端的client-identifier2. 用mac地址绑定Router(config)#ipdhcp pool BINDRouter(config-dhcp)#host192.168.1.111 255.255.255.0Router(config-dhcp)#hardware-address hardware-address type //上面命令中的type参数,用来指示这个硬件地址的硬件类型,如type为1,则类型为ethernet,如果type为6,则类型为802,默认是ethernet3. 从网络读取绑定Router(config)#ipdhcp pool BINDRouter(config-dhcp)#originfile flash:CCIE.txt
6. EtherChannel1. 注意事项隶属于一个port-channel的物理接口需有相同的如下配置− 相同的speed和duplex− 相同的接口模式(access、trunk)− 如果是trunk模式,那么native vlan及allowed vlan需相同− 如果是access模式,所属vlan需相同2. 配置实现1. 二层捆绑
Sw1(config)#interface rangefastEthernet 0/1 –2 //进入接口范围Sw1(config-if-range)#switchport //将接口配置为二层接口Sw1(config-if-range)#switchport trunkencapsulation dot1q //trunk封装协议为dot1qSw1(config-if-range)#switchport modetrunk //设置接口模式为Trunk模式Sw1(config-if-range)#channel-protocol{pagp | lacp}Sw1(config-if-range)#channel-group 1mode {desirable | active | on} //配置etherchannel,ID为1,模式为desirable Sw1#Showetherchannel 1 summary //查看命令2. 三层捆绑 Sw1(config)#interfacerange fastEthernet 0/1 – 2 Sw1(config-if-range)#no switchport //配置L3接口Sw1(config-if-range)#no ip addressSw1(config-if-range)#channel-group 1mode desirableSw1(config-if-range)#no shutdownSw1(config)#interface port-channel 1//进入port-channel组1配置IPSw1(config-if)#ip address 172.16.10.1255.255.255.0Sw1(config-if)#no shu Sw1#Showetherchannel 1 summary //查看命令3. 负载均衡EtherChannel支持在同一个port-channel的链路中执行负载均衡负载均衡动作可以基于MAC、端口、IP(源IP、目的IP或两者)默认的行为:源目IP地址对(src-dst-ip)
Switch(config)#port-channelload-balance src-dst-ip Switch(config)#showetherchannel load-balance=================================
加了图片大小就超了,大家直接下载源文件吧。
{:6_267:} 学习一下 謝謝樓主分享! CCNP交换机部分的学习笔记 thanks your sharing! 谢谢博主分享! 谢谢老板慷慨分享! thanks for sharing thanks for sharing Thanks for sharing 谢谢分享! Nice! 感謝您分享學習{:6_299:}{:6_299:}{:6_299:}{:6_299:} {:6_267:}{:6_267:}{:6_267:}
页:
[1]
2