CISCO三层交换机配置实例.docx
《CISCO三层交换机配置实例.docx》由会员分享,可在线阅读,更多相关《CISCO三层交换机配置实例.docx(7页珍藏版)》请在冰豆网上搜索。
![CISCO三层交换机配置实例.docx](https://file1.bdocx.com/fileroot1/2023-4/16/cda7d148-0201-45cb-be4e-30a75434cd2c/cda7d148-0201-45cb-be4e-30a75434cd2c1.gif)
CISCO三层交换机配置实例
比较全面的三层交换机配置实例(带命令解释哟!
)
Enable//进入私有模式
Configureterminal//进入全局模式
servicepassword-encryption//对密码进行加密
hostnameCatalyst3550-12T1//给三层交换机定义名称
enablepassword123456.//enable密码
Enablesecret654321//enable的加密密码(应该是乱码而不是654321这样)
Ipsubnet-zero//允许使用全0子网(默认都是打开的)
Ipname-server172.16.8.1172.16.8.2//三层交换机名字Catalyst3550-12T1对应的IP地址是172.16.8.1
Servicedhcp//提供DHCP服务
iprouting//启用三层交换机上的路由模块
Exit
Vtpmodeserver//定义VTP工作模式为sever模式
Vtpdomaincentervtp//定义VTP域的名称为centervtp
Vlan2namevlan2//定义vlan并给vlan取名(如果不取名的话,vlan2的名字应该是vlan002)
Vlan3namevlan3
Vlan4namevlan4
Vlan5namevlan5
Vlan6namevlan6
Vlan7namevlan7
Vlan8namevlan8
Vlan9namevlan9
Exit
interfacePort-channel1//进入虚拟的以太通道组1
switchporttrunkencapsulationdot1q//给这个接口的trunk封装为802.1Q的帧格式
switchportmodetrunk//定义这个接口的工作模式为trunk
switchporttrunkallowedvlanall//在这个trunk上允许所有的vlan通过
Interfacegigabitethernet0/1//进入模块0上的吉比特以太口1
switchporttrunkencapsulationdotlq//给这个接口的trunk封装为802.1Q的帧格式
switchportmodetrunk//定义这个接口的工作模式为trunk
switchporttrunkallowedvlanall//在这个trunk上允许所有的vlan通过
channel-group1modeon//把这个接口放到快速以太通道组1中
Interfacegigabitethernet0/2//同上
switchporttrunkencapsulationdotlq
switchportmodetrunk
switchporttrunkallowedvlanall
channel-group1modeon
port-channelload-balancesrc-dst-ip//定义快速以太通道组的负载均衡方式(依*源和目的IP的方式)
interfacegigabitethernet0/3//进入模块0上的吉比特以太口3
switchporttrunkencapsulationdotlq//给trunk封装为802.1Q
switchportmodetrunk//定义这个接口的工作模式为trunk
switchporttrunkallowedvlanall//允许所有vlan信息通过
interfacegigabitethernet0/4//同上
switchporttrunkencapsulationdotlq
switchportmodetrunk
switchporttrunkallowedvlanall
interfacegigbitethernet0/5//同上
switchporttrunkencapsulationdotlq
switchportmodetrunk
switchporttrunkallowedvlanall
interfacegigbitethernet0/6//同上
switchporttrunkencapsulationdotlq
switchportmodetrunk
switchprottrunkallowedvlanall
interfacegigbitethernet0/7//进入模块0上的吉比特以太口7
Switchportmodeaccess//定义这个接口的工作模式为访问模式
switchportaccessvlan9//定义这个接口可以访问哪个vlan(实际就是分配这个接口到vlan)
noshutdown
spanning-treevlan6-9cost1000//在生成树中,vlan6-9的开销定义为10000
interfacerangegigabitethernet0/8–10//进入模块0上的吉比特以太口8,9,10
switchportmodeaccess//定义这些接口的工作模式为访问模式
switchportaccessvlan8//把这些接口都分配到vlan8中
noshutdown
spanning-treeportfast//在这些接口上使用portfast(使用portfast以后,在生成树的时候不参加运算,直接成为转发状态)
interfacegigabitethernet0/11//进入模块0上的吉比特以太口11
switchporttrunkencapsulationdotlq//给这个接口封装为802.1Q
switchportmodetrunk//定义这个接口的工作模式为trunk
switchporttrunkallowedvlanall//允许所有vlan信息通过
interfacegigabitethernet0/12//同上
switchporttrunkencapsulationdotlq
switchportmodetrunk
switchporttrunkallowedvlanall
interfacevlan1//进入vlan1的逻辑接口(不是物理接口,用来给vlan做路由用)
ipaddress172.16.1.7255.255.255.0//配置IP地址和子网掩码
noshutdown
standby1ip172.16.1.9//开启了冗余热备份(HSRP),冗余热备份组1,虚拟路由器的IP地址为172.16.1.9
standby1priority110preempt//定义这个三层交换机在冗余热备份组1中的优先级为110,preempt是用来开启抢占模式
interfacevlan2//同上
ipaddress172.16.2.252255.255.255.0
noshutdown
standby2ip172.16.2.254
standby2priority110preempt
ipaccess-group101in//在入方向上使用扩展的访问控制列表101
interfacevlan3//同上
ipaddress172.16.3.252255.255.255.0
noshutdown
standby3ip172.16.3.254
standby3priority110preempt
ipaccess-group101in
interfacevlan4//同上
ipaddress172.16.4.252255.255.255.0
noshutdown
standby4ip172.16.4.254
standby4priority110preempt
ipaccess-group101in
interfacevlan5
ipaddress172.16.5.252255.255.255.0
noshutdown
standby5ip172.16.5.254
standby5priority110preempt
ipaccess-group101in
interfacevlan6
ipaddress172.16.6.252255.255.255.0
noshutdown
standby6ip172.16.6.254
standby6priority100preempt
interfacevlan7
ipaddress172.16.7.252255.255.255.0
noshutdown
standby7ip172.16.7.254
standby7priority100preempt
interfacevlan8
ipaddress172.16.8.252255.255.255.0
noshutdown
standby8ip172.16.8.254
standby8priority100preempt
interfacevlan9
ipaddress172.16.9.252255.255.255.0
noshutdown
standby9ip172.16.9.254
standby9priority100preempt
access-list101denyipany172.16.7.00.0.0.255//扩展的访问控制列表101
access-list101permitipanyany
Interfacevlan1//进入vlan1这个逻辑接口
Iphelper-address172.16.8.1//可以转发广播(helper-address的作用就是把广播转化为单播,然后发向172.16.8.1)
Interfacevlan2
Iphelper-address172.16.8.1
Interfacevlan3
iphelper-address172.16.8.1
interfacevlan4
iphelper-address172.16.8.1
interfacevlan5
iphelper-address172.16.8.1
interfacevlan6
iphelper-address172.16.8.1
interfacevlan7
iphelper-address172.16.8.1
interfacevlan9
iphelper-address172.16.8.1
routerrip//启用路由协议RIP
version2//使用的是RIPv2,如果没有这句,则是使用RIPv1
network172.16.0.0//宣告直连的网段
exit
iproute0.0.0.00.0.0.0172.16.9.250//缺省路由,所有在路由表中没有办法匹配的数据包,都发向下一跳地址为172.16.9.250这个路由器
linecon0
lineaux0
linevty015//telnet线路(路由器只有5个,是0-4)
password12345678//login密码
login
end
copyrunning-configstartup-config保存配置