当前位置:文档之家› cisco交换机配置简单教程

cisco交换机配置简单教程

一、标识交换机二、设置口令及用户三、配置VTP(Vlan中继协议)四、配置中继线(Trunk)五、创建、描述Vlan及设置Vlan IP六、划分、描述及设置Vlan端口七、配置STP(生成树协议)八、启用Vlan间Router九、配置ACL十、配置DHCP中继代理十一、配置DHCP服务器十二、配置HSRP(热备路由协议)十三、保存配置附1:命令行编辑键附2:SHOW命令附7:ACL例子一、标识交换机Switch#configure terminal 进入配置状态Switch(config)#hostname “hostname”设置Switch名称Switch (config)#no hostname 取消Switch名称Switch(config)#end 结束本次配置二、设置口令及用户Switch#configure terminal 进入配置状态Switch(config)#enable secret “password”设置特权模式口令Switch(config)#no enable secret 取消特权模式口令Switch(config)#enable password “password”设置EXEC模式口令Switch(config)#no enable password 取消EXEC模式口令witch(config)#username “username”privilege “num”secret “password”建立本地用户及口令Switch(config)#no username “username”删除本地用户Switch(config)#service password-encryption 加密所有明文口令Switch(config)#no password-encryption 拒绝加密所有明文口令Switch(config)#end 结束本次配置1、配置console用户用口令Switch#configure terminal 进入配置状态Switch(config)#line console 0 进入console口配置状态Switch(config-line)#login local 设置登录模式为本地用户验证模式Switch(config-line)#no login local 取消本地用户验证模式Switch(config-line)#end 结束本次配置或Switch#configure terminal 进入配置状态Switch(config)#line console 0 进入console口配置状态Switch(config-line)#login 设置登录模式为线性登录模式Switch(config-line)#password “password”设置线性登录模式口令Switch(config-line)#no login 取消线性登录模式Switch(config-line)#end 结束本次配置2、配置tenlnet(vty)用户及口令Switch#configure terminal 进入配置状态Switch(config)#line vty 0 15 进入vty配置状态Switch(config-line)#login local 设置登录模式为本地用户验证模式Switch(config-line)#no login local 取消本地用户验证模式Switch(config-line)#end 结束本次配置或Switch#configure terminal 进入配置状态Switch(config)#line vty 0 15 进入vty配置状态Switch(config-line)#login 设置登录模式为线性登录模式Switch(config-line)#password “password”设置线性登录模式口令Switch(config-line)#no login 取消线性登录模式Switch(config-line)#end 结束本次配置三、配置VTP(Vlan中继协议)Switch#vlan database 进入vlan数据库配置状态Switch(vlan)#vtp domain “domainname”设置vtp域名称Switch(vlan)#vtp server|client| transparent 设置vtp模式Switch(vlan)#vtp password “password”设置vtp口令Switch(vlan)#no vtp password 取消vtp口令Switch(vlan)#exit 退出vlan数据库配置状态四、配置trunk(中继线)Switch#configure terminal 进入配置状态Switch(config)#interface “interface mod/port”进入端口配置状态Switch(config-if)#switchport trunk encapsulation dot1q|isl| negotiate 设置干道封装模式Switch(config-if)#switchport mode trunk 设置端口为干道模式Switch(config-if)#no shutdown 启用端口Switch(config-if)#end 结束本次配置或Switch#configure terminal 进入配置状态Switch(config)#interface range “interface mod/port -port”进入端口组配置状态Switch(config-if-range)#switchport trunk encapsulation dot1q|isl| negotiate 设置干道封装模式Switch(config-if-range)#switchport mode trunk 设置端口为干道模式Switch(config-if-range)#no shutdown 启用端口Switch(config-if-range)#end 结束本次配置五、创建、描述Vlan及设置Vlan IPSwitch#vlan database 进入vlan数据库配置状态Switch(vlan)#vlan “vlan-num”name “vlan-name”建立vlan及名称Switch(vlan)#no vlan “vlan-num”删除vlanSwitch(vlan)#exit 退出vlan数据库配置状态Switch#configure terminal 进入配置状态Switch(config)#interface vlan “vlan-num”进入vlan配置状态Switch(config-if)#description “description”描述vlanSwitch(config-if)#no description 取消描述Switch(config-if)#ip address “ip-address subnet-mask”设置vlan 网关的ip 地址Switch(config-if)#no shutdown 启用vlanSwitch(config-if)#end 结束本次配置六、划分、描述及设置Vlan端口Switch#configure terminal 进入配置状态Switch(config)#interface “interface mod/port”进入端口配置状态Switch(config-if)#description “description”描述端口Switch(config-if)#speed auto|100|10 设置端口速率模式Switch(config-if)#duplex auto|full|half 设置端口双工模式Switch(config-if)#switchport mode access 设置端口为访问模式Switch(config-if)#switchport access vlan “vlan-num”设置端口所属Vlan Switch(config-if)#no shutdown 启用端口Switch(config-if)#end 结束本次配置或Switch#configure terminal 进入配置状态Switch(config)#interface range “interface mod/port -port”进入端口组配置状态Switch(config-if-range)#description “description”描述端口Switch(config-if-range)#speed auto|100|10 设置端口速率模式Switch(config-if-range)#duplex auto|full|half 设置端口双工模式Switch(config-if-range)#switchport mode access 设置端口为访问模式Switch(config-if-range)#switchport access vlan “vlan-num”设置端口所属Vlan Switch(config-if-range)#no shutdown 启用端口Switch(config-if-range)#end 结束本次配置七、配置STP(生成树协议)Switch#configure terminal 进入配置状态Switch(config)#spanning-tree portfast default 设置所有访问端口为快速模式Switch(config)#no spanning-tree portfast default 取消所有访问端口为快速模式Switch(config)#spanning-tree uplinkfast 设置上行端口为快速模式Switch(config)#no spanning-tree uplinkfast 取消上行端口为快速模式Switch(config)#end 结束本次配置或Switch#configure terminal 进入配置状态Switch(config)#interface “interface mod/port”进入端口配置状态Switch(config-if)#spanning-tree portfast 设置端口为快速模式Switch(config-if)#no shutdown 启用端口Switch(config-if)#end 结束本次配置或Switch#configure terminal 进入配置状态Switch(config)#interface range “interface mod/port -port”进入端口组配置状态Switch(config-if-range)# spanning-tree portfast 设置端口为快速模式Switch(config-if-range)#no shutdown 启用端口Switch(config-if-range)#end 结束本次配置八、启用Vlan间RouterSwitch#configure terminal 进入配置状态Switch(config)#ip routing 启用ip 路由Switch(config)#ip route “Destination-prefix Destination-prefix-mask Forwarding-router’s-address”Switch(config)#end 结束本次配置九、配置ACLSwitch#configure terminal 进入配置状态Switch(config)#access-list “standard-acl-num”permit|deny “source-address source-wildcard”设置标准aclSwitch(config)#access-list “extend-acl-num”permit|deny ip “source-add source-wildcard Destination-add Destination-wildcard”设置扩展aclSwitch(config)#end 结束本次配置Switch#configure terminal 进入配置状态Switch(config)#interface vlan “vlan-num”进入vlan配置状态Switch(config-if)#ip access-group “acl-num”in|out 应用acl到vlanSwitch(config-if)#end 结束本次配置Switch#configure terminal 进入配置状态Switch(config)#line vty 0 15 进入vty配置状态Switch(config-line)#access-class “acl-num”in|out 应用acl到vtySwitch(config-if)#end 结束本次配置例:Switch(config)#access-list 101 deny ip host 192.168.2.11 host 192.168.10.21Switch(config)#access-list 102 deny ip host 192.168.2.13 192.168.10.0 0.0.0.255Switch(config)#access-list 103 deny ip 192.168.2.0 0.0.0.255 192.168.10.0 0.0.0.255Switch(config)# access-list 104 deny ip 192.168.2.0 0.0.0.255 host 192.168.10.25十、配置DHCP中继代理Switch#configure terminal 进入配置状态Switch(config)#service dhcp 启用dhcp服务Switch(config)#ip dhcp relay information option 启用dhcp代理服务Switch(config)#interface vlan “vlan-num”进入vlan配置状态Switch(config-if)#ip helper-address “ip-address”启用dhcp代理服务器ip地址Switch(config-if)#end 结束本次配置十一、配置DHCP服务器Switch#configure terminal 进入配置状态Switch (config)#ip dhcp pool “Pool-name”设置dhcp地址池名称Switch (dhcp-config)#network “Network-num Network-mask”设置dhcp地址池ip围Switch (dhcp-config)# dns-server “ip-address”为客户机分配DNS服务器ip地址Switch (dhcp-config)#netbios-name-server “ip-address”为客户机分配WINS服务器ip地址Switch (dhcp-config)#default-router “ip-address”为客户机分配默认网关ip地址Switch(config-if)#end 结束本次配置Switch#configure terminal 进入配置状态Switch(config)#service dhcp 启用dhcp服务wyz(config)#ip dhcp excluded-address “Low-ip-address High-ip-address”设置保留ip地址Switch(config-if)#end 结束本次配置十二、配置HSRP(热备路由协议)Switch#configure terminal 进入配置状态Switch(config)#interface vlan “vlan-num”进入vlan配置状态Switch(config-if)#ip address “ip-address subnet-mask”设置vlan 物理ip 地址Switch(config-if)#standby “group-num”ip “virtual-ip-address”设置vlan 虚拟ip 地址Switch(config-if)#standby priority “Priority-value”设置路由器优先等级Switch(config-if)#standby preempt 设置hsrp抢占功能Switch(config-if)#standby timers “Hello-interval-in-seconds Hold-time-in-seconds”设置hello 信息Switch(config-if)#end 结束本次配置十三、保存配置Switch#write memory或Switch#copy running-config startup-config附1:命令行编辑键TAB 补全命令?查看可用命令Ctrl + P 粘贴历史命令Ctrl + E 将光标移至命令末尾Ctrl + F 将光标向前移动Ctrl + B 将光标向后移动Ctrl + Z 返回#命令模式Ctrl + U Clear Line and Put in BufferCtrl + W Delete Word Backwards and Put in BufferCtrl + Y Paste Buffer ContentsCtrl + X Clear Line to the Left and Put in BufferCtrl + T Flip Last 2 CharactersCtrl + J ReturnCtrl + L Refresh LineCtrl + I Refresh Line and Goto EndCtrl + K Delete everything on the Right of cursorCtrl + V Allows to type control characterCtrl + M ReturnCtrl + H Backspace Character to the LeftCtrl + R 刷新行附2:SHOW命令Switch#show version 显示版本信息Switch #show arp | include “ip-address”显示ip地址对应的mac地址信息Switch#show mac-address-table 显示mac地址信息Switch#show mac-address-table | include “mac-address”格式:xxxx.xxxx.xxxx.xxxx Switch #show mac-address-table dynamic address “mac-address”显示mac地址对应的端口信息Switch#show mac-address-table dynamic interface “interface mod/port”显示端口对应的mac 地址信息Switch#show tech-support 显示技术支持信息Switch#show interfaces 显示接口信息Switch#show vlan 显示vlan信息Switch#show startup-config 显示启用配置文件Switch#show running-config 显示运行配置文件Switch#show ip route 显示ip路由状态Switch#clear counters interface “interface mod/port”清除端口计数器Switch(config)#default interface “interface mod/port”恢复端口出厂设置Switch#clear interface “interface mod/port”重置端口的硬件逻辑keyada#show cdp neighbors “interface mod/port”detail附7:ACL例子VLAN1需实现以下效果:1、VLAN1主机192.168.1.240可以访问所有网段;2、VLAN1其余主机可以访问除VLAN2、VLAN3及VLAN4外所有网段。

相关主题