本帖最后由 miucat 于 2023-9-23 23:54 编辑
由于系统文章大小限制,未能加图,请大家直接下载原文附件。
========================================
1. 以太网 1. 接口MTU和ip MTU Router(config-if)#mtu 1500 Router(config-if)#ip mtu 1500 Router#sh int s1/0 Router#sh ip int s1/0 2. 管理MAC表 48位,点分十六进制表示 Switch#show mac address-table Switch#clear mac address-table Switch(config)#mac address-table static aaaa.bbbb.cccc vlan 10interface e0/0 2. 二层交换 1. Protectedport Switch(config-if)#switchportprotected 2. Native Vlan Switch(config-if)#switchport trunk native vlan 10 Switch(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 trunk Switch#showinterface f0/8 switchport 将接口设置为DTP动态协商,可auto或desirable Switch(config-if)#switchport nonegotiate 将接口设置为nonegotiate,不发送DTP帧,如果配置为非协商,那么必须手工配置接口模式为access或trunk Switch(config-if)#switchportmode dynamic [auto | desirable] 配置接口为协商模式 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 except all VLANsexcept the following none no VLANs remove remove VLANs from the current list Switch(config-if)#switchporttrunk allowed vlan remove 20
4. VTP 1. VTP配置 Switch1(config)#vtp domain cisco Switch1(config)#vtp mode {server | client|transparent} Switch1(config)#vtp password 123456 Switch1#sh vtp password 2. 查看VTP状态 Switch1#sh vtp status 3. 查看trunk及allowed vlan状态 Switch1#shint trunk 4. VTPpruning 开启VTP修剪 Switch2(config)#vtp pruning 5. 私有VLAN(PVLAN) 1. 创建主VLAN: Vlan 100 Private-vlan primary 2. 创建辅助VLAN Vlan 101 Private-vlan community Vlan 102 Private-vlan ioslate 3. 配置主VLAN,将二层辅助VLAN关联到主VLAN Vlan 100 Private-vlan association 101,102 4. 将辅助VLAN映射到主VLAN的SVI接口,从而允许PVLAN入口流量的三层交换。 Interface vlan100 Private-vlan mapping add 101,102 5. 配置接口 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- 2 Sw(config-if)#switchportmode private-vlan host Sw(config-if)#switchportprivate-vlan host-association 100 202 Sw(config)#interface rangefa 0/3 - 4 Sw(config-if)#switchportmode private-vlan host Sw(config-if)#switchportprivate-vlan host-association 100 201 3. Spanning-tree
1. 802.1D 1. 每个广播域选择一个根桥 桥优先级小的,然后桥MAC地址小的,当选根桥。 桥ID由桥优先级和桥MAC地址组成。 根桥是可以抢占的 2. 每个非根桥上选择一个根端口 到根桥的最低Cost 最低的发送者的桥ID(先比桥优先级小的,再比桥MAC地址小的) 最低的发送者端口ID(先比端口优先级小的,再比端口编号小的)
3. 每个段选择一个指定端口 4. 阻塞非指定端口 Switch#sh int | inbia //可以查看交换机桥MAC和接口MAC Switch#shspanning-tree //可以查看spanning-tree信息,桥优先级、接口优先级等 Switch(config-if)#spanning-treecost 100000 //设置接口开销cost Switch#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 [trunk] //将特定接口激活portfast特性 Switch(config-if)#switchporthost //宏命令,指定接口mode为access并开启portfast特性 bpduguard特性 Switch(config)#spanning-treeportfast bpduguard default //为所有激活了portfast的接口激活bpduguard Switch(config-if)#spanning-treebpduguard enable //在特定接口激活bpduguard特性 Bpdufilter特性 Switch(config)#spanning-treeportfast bpdufilter default Switch(config-if)#spanning-treebpdufilter enable Uplinkfast特性(强烈建议在末梢交换设备配置) Switch(config)#spanning-treeuplinkfast Switch#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 [aggressive] //特定接口上激活UDLD 相关命令 Switch(config)#errdisable recovery? Switch(config)#errdisablerecovery interval 100 //修改errdisable的时间间隔 Switch#show errdisable recovery 2. Pvst+ Switch#shspanning-tree //查看spanning-tree状态信息 Switch(config)#spanning-treevlan 10 //针对vlan10开启spanning-tree(默认pvst+) Switch(config)#nospanning-tree vlan 10 Switch(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]修改cost Switch(config-if)#spanning-treevlan 10 port-priority 64 //[针对vlan10]修改接口优先级 Switch(config)#spanning-treevlan 10 hello-time 3 Switch(config)#spanning-treevlan 10 forward-time 10 Switch(config)#spanning-treevlan 10 max-age 30 Switch#debugspanning-tree event Switch(config-if)#spanning-treelink-type {point-to-point | shared}
3. RSTP(802.1W),思科是per-vlan rstp Switch(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/0 R1(config-if)#Noshutdown R1(config)#Interfacef0/0.10 R1(config-if)#Encapsulationdot1Q 10 R1(config-if)#Ipadd 192.168.10.254 255.255.255.0 R1(config-if)#Noshutdown R1(config)#Interfacef0/0.20 R1(config-if)#Encapsulationdot1Q 20 R1(config-if)#Ipadd 192.168.20.254 255.255.255.0 R1(config-if)#Noshutdown 2. 三层交换机基本配置 Switch(config)# iprouting //开启三层交换机的路由功能 Switch(config)# vlan10 Switch(config-vlan)# nameClassroom //创建VLAN Switch(config)# interfacevlan 10 Switch(config-if)# ipaddress 192.168.10.254 255.255.255.0 Switch(config-if)# noshutdown //配置VLAN对应的SVI接口 Switch(config)# interfacefast 0/1 Switch(config-if)# noswitchport Switch(config-if)# ipaddress 192.168.255.1 255.255.255.0 Switch(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)# vlan10 Switch(config)# vlan20 Switch(config)# vlan255 Switch(config)# interfacefast0/1 Switch(config-if)# switchportaccess vlan 10 Switch(config)# interfacefast0/2 Switch(config-if)# switchportaccess vlan 20 Switch(config)# interfacefast0/15 Switch(config-if)# switching Switch(config-if)# switchportmode trunk Switch(config)# interfacevlan 255 Switch(config-if)# ipaddress 192.168.255.1 255.255.255.0 Switch(config)# ipdefault-gateway 192.168.255.254 !!为接入交换机自身设置的网关 2. 核心交换机的配置: Switch(config)#vlan 10 Switch(config)# vlan20 Switch(config)# vlan255 Switch(config)# interfacefast0/15 Switch(config-if)# switchportmode trunk Switch(config)# interfacevlan 10 Switch(config-if)# ipaddress 192.168.10.254 255.255.255.0 Switch(config)#interface vlan 20 Switch(config-if)# ipaddress 192.168.20.254 255.255.255.0 Switch(config)#interface vlan 255 Switch(config-if)# ipaddress 192.168.255.254 255.255.255.0 5. DHCP 1. 基本配置 Router(config)#serviceDHCP //开启DHCP服务。 Router(config)#ipdhcp pool [pool name] //定义DHCP地址池,一个网段对应一个地址池 Router(config-dhcp)#network[network address][subnet mask] //定义地址池关联的网段 Router(config-dhcp)#default-router[host address] //定义分配给客户端的网关IP Router(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 BIND Router(config-dhcp)#host192.168.1.111 255.255.255.0 Router(config-dhcp)#client-identifier unique-identifier //可以在服务器上通过show ipdhcp bingding抓取客户端的client-identifier 2. 用mac地址绑定 Router(config)#ipdhcp pool BIND Router(config-dhcp)#host192.168.1.111 255.255.255.0 Router(config-dhcp)#hardware-address hardware-address type //上面命令中的type参数,用来指示这个硬件地址的硬件类型,如type为1,则类型为ethernet,如果type为6,则类型为802,默认是ethernet 3. 从网络读取绑定 Router(config)#ipdhcp pool BIND Router(config-dhcp)#originfile flash:CCIE.txt
6. EtherChannel 1. 注意事项 隶属于一个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封装协议为dot1q Sw1(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 address Sw1(config-if-range)#channel-group 1mode desirable Sw1(config-if-range)#no shutdown Sw1(config)#interface port-channel 1//进入port-channel组1配置IP Sw1(config-if)#ip address 172.16.10.1255.255.255.0 Sw1(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 =================================
加了图片大小就超了,大家直接下载源文件吧。
|