我的ccna上机实验文档 -- 实验指导书 1 交换机基本配置 A 首先清除以前的交换机配置 1900 del nvram reload 2950 erase start del vlan.dat reload 然后配置相应的交换机名称 ************************************************************** B.1900 Ip add 192.168.0.100 255.255.255.0 无需配置vty线路,只需配置secret密码即可 ************************************************************** C 2950 Int vlan 1 Ip add 192.168.0.100 255.255.255.0 No shut Line vty 0 4 Login Password cisco 然后配置secret密码。 Enable secret cisco 这样一个同学可以通过consol连接,另外一个同学可以通过telnet连接。 ************************************************************** ************************************************************** 1900 Int f0/2 Sw(config-if)#vlan-membership static vlan 2 2950 int f0/2 switchport access vlan 2 sh vlan 2 VTP(VLAN TRUNK PROTOCOL) 实验 A 首先清除以前的交换机配置 1900 del nvram reload 2950 erase start del vlan.dat reload B 配置TRUNK 1900:ISL int f0/26 trunk on 验证 show trunk a ************************************************************** 2950: 802.1q int f0/24 swithchport mode trunk 验证show int f0/24 swithchport 或者 show int f0/24 trunk ************************************************************** C配置VTP 1900 sw1(config)#vtp server vtp domain tyl 验证 show vtp 2950 sw2#vlan database sw2(vlan)# vtp server vtp domain tyl 验证 show vtp status 主要看配置版本号,域名和vlan数量等等 创建一个新的vlan,看对方是否可以收到。 ************************************************************** 3 vlan间路由 (可以只用一台交换机和一台有快速以太口的路由器,也可以用两台,但一定要保证干道畅通) trunk trunk sw1 sw2 router(f0/0.1 100.0.0.1/24) (f0/0.2 200.0.0.1/24) 100.0.0.2/24 200.0.0.2/24 vlan100 vlan200 sw3 sw4 router(f0/1.1 300.0.0.1/24,作为PC1的网关) (f0/1.2 400.0.0.1/24,作为PC2的网关) 300.0.0.2/24 400.0.0.2/24 vlan300 vlan400 交换机部分 A 配置各交换机干道端口保证干道畅通 B 配置连接路由器的交换机以太口,保证干道畅通,强调这一步很重要 C 配置VLAN,将端口指定到相应的VLAN去。 PC部分 按图配置好IP地址子网掩码和默认网关 路由器部分 对于ISL的干道封装 int f0/0 no ip add no shu int f0/0.1 encapsulation ISL 100 ip add 100.0.0.1 255.255.255.0 int f0/0.2 encapsulation ISL 200 ip add 200.0.0.1 255.255.255.0 对于802.1Q的干道封装 int f0/1 no ip add no shu int f0/1.3 encapsulation dot1q 300 ip add 300.0.0.1 255.255.255.0 int f0/1.4 encapsulation dot1q 400 ip add 400.0.0.1 255.255.255.0 验证:PC可以互相ping通即可 注:如果某台PC处于vlan1 ,那么就有针对native vlan 的专门配置: 有两种配置方法: A 子接口(本实验室不支持) Int f0/1.1 Encapsulation d0t1q 1 native(但要求IOS版本在12.2以上) Ip add …… B 在物理接口配置 Int f0/1 Ip add ……. No shu 路由器部分 一 路由器的基本配置 最常用命令:sh ip int brief(观察 sh run sh ver sh flash sh int sh ip pro sh ip route 配置DCE时钟: router# show controllers Type Port <--确定DCE接口--> router(confin-if)# clock rate 64000 <--进入DCE接口设置时钟速率--> router(config-if)# ^z 作者: 啥都不会 2006-1-9 09:26   回复此发言 -------------------------------------------------------------------------------- 2 我的ccna上机实验文档 在配置前做一些优化工作: 1.禁用DNS: (防止打错命令,系统解析耗费时间) router(config)# no ip domain-lookup router(config)# ^z 2.Line con 0 no exec-timeout 0 0(防止系统超时退出特权模式) logg syn(避免被系统出现的控制信息打断命令) 设置主机名: router(config)# hostname ***** router(config)# ^z router(config)# ^z 设置用户模式密码: router(config)# line console 0 router(config-line)# login router(config-line)# password cisco router(config-line)# ^z 设置Telnet密码: router(config)# line vty 0 4 router(config-line)# login router(config-line)# password cisco router(config-line)# ^z 设置特权模式密码: router(config)# enable password Set-Password <--不加密的密码,明码--> router(config)# enable secret Set-Password <--经过加密的密码--> router(config)# ^z 给所有密码加密: router(config)# service password-ancryption Set-Password-Here router(config)# no service password-ancryption <--取消加密--> router(config)# ^z show run (验证) 设置登录Banner: router(config)# banner motd 分隔符 Set-Banner-Information-Here 分隔符 <--前后分隔符一定要一致--> 设置接口的描述信息: router(config-if)# description Set-Port-Information-Here router(config)# ^z CDP的控制: router(config-if)# cdp enable <--在指定端口启用CDP,缺省--> router(config-if)# no cdp enable <--在指定端口关闭CDP--> router(config)# cdp run <--使所有端口启用CDP--> router(config)# no cdp run <--使所有端口关闭CDP--> Ping的使用: router# ping IP-Address router# ping <--扩展Ping命令--> Protocol [ip]:[ Protocol-Type ] <--选择协议类型--> Target IP address:IP-Address <--输入测试地址--> Repeat count [5]: <--选择发送的ICMP包数量--> Datagram size [100]: <--选择每个包的大小--> Timeout in seconds [2]: <--设置每个包的超时时间--> Extended commands [n]:y <--使用扩展Ping命令--> Sweep range of sizes [n]: Tracee的使用: router# trace IP-Address [ Host-Name ] 二 路由协议的配置 拓扑图: pod2 1 静态路由 启动接口,分配IP地址: ip route (非直连的网段) 子网掩码 下一条地址 注:路由是双向的,即使你的路由器上有到达对方的路由,如果对方没有回来的路由,也ping不通) show ip route(可以看到S的路由) ping的实验 trace的实验 2 RIP 删除原来的静态路由(因为Static路由的AD值低,不然不可以学习到RIP) no ip route ***** ****** ****** ****** 启动接口,分配IP地址: router> router>enable router# router#configure terminal router(config)# router(config)# interface Type Port(按自己所用路由器的接口配置相应的IP,记住子网掩码不要配错) router(config-if)# no shutdown router(config-if)#ip address IP-Address Subnet-Mask router(config-if)#^z 配置RIP路由协议:30秒更新一次(sh ip protocol 可以验证) router(config)# router rip router(config-if)# network Network-Number <--通告标准A,B,C类网--> router(config-if)#^z show ip route (如果所有的路由器都已经配好RIP那么应该可以看到除直连接口外通过RIP学习到的路由) debug ip rip clear ip route *(可以清空动态路由,重新学习,这样观察debug信息) 3 IGRP 可以不删除以前配置的RIP,因为它的AD值低,比RIP优秀。 删除RIP可以用 no router rip 作者: 啥都不会 2006-1-9 09:26   回复此发言 -------------------------------------------------------------------------------- 3 我的ccna上机实验文档 配置IGRP路由协议:90秒更新一次 router(config)# router igrp AS-Number <-- AS-Number范围1~65535--> 切记每个学员配置的路由器必须在相同的自治系统内。 router(config-if)# network Network-Number <--通告标准A,B,C类网--> router(config-if)#^z sh ip pro sh ip route ( 要求出现所有拓扑内网段的路由) ping trace debug ip igrp event clear ip route *(可以清空动态路由,重新学习,这样观察debug信息) copy run start 删除igrp可以用 no router rip 自治系统号 3 EIGRP 删除以前配置的RIP和IGRP以免干扰。 删除RIP可以用 no router rip 删除IGRP可以用 no router igrp 自治系统号 配置EIGRP路由协议: router(config)# router eigrp AS-Number <-- AS-Number范围1~65535--> 切记每个学员配置的路由器必须在相同的自治系统内。 router(config-if)# network Network-Number <--因为是classless路由协议,可以通告大类网络、子网地址甚至接口地址--> router(config-if)#^z eg: router eigrp 100 network 172.16.0.17 network 172.16.0.2 or router eigrp 100 network 172.16.0.0(大类网络) network 后接的网络不需要要接子网掩码(根据IOS版本不同有变化) sh ip pro sh ip route ( 要求出现所有拓扑内网段的路由) sh ip eigrp topology(看拓扑数据库) sh ip eigrp neighbors(看邻接数据库) ping trace debug ip eigrp 配置OSPF 路由协议(单区域OSPF) 删除eigrp的路由协议 no router eigrp 自治系统号 eg: router ospf 100 network 172.16.0.17 0.0.0.0 area 0 network 172.16.0.2 0.0.0.0 area 0 or router ospf 100 network 172.16.0.0 0.0.255.255 area 0 or router ospf 100 network 0.0.0.0 255.255.255.255 area 0 (将所有的接口赋予area0,但实施不够精确,容易出错,推荐第一种配置) 验证: sh ip protocol show ip ospf interface(显示所有的ospf配置接口的信息) show ip ospf neighbor(显示所有的ospf邻居信息) option: passive-interface (在路由器模式下,在该端口上关闭发送,但仍会接受更新-) show ip route (验证路由) 访问列表实验: 拓扑图:(两人合作,shutdown连接另外一个路由器的端口,如图所示) 1. 标准的访问列表 a.增加一个loopback接口,相当于增加一个网段,IP 地址1.1.1.1/32和2.2.2.2/32 b. 配置好路由协议,保证3个网段可以互相ping通。Eg:在p2r1上可以ping通2.2.2.2 C. 设置ACL,(在p2r2上) Access-list 1 permit 1.1.1.1 0.0.0.0(or access-list 1 permit 1.1.1.1) 隐含的deny all d.应用在接口上(p2r2的S0口上) ip access-group 1 in e.验证:(在p2r1执行) 用正常的ping,ping 2.2.2.2,应该ping不同,因为ping包的源IP地址是172.16.0.17,将被访问列表拒绝。 用扩展的ping,改变ping包的源地址为1.1.1.1,这样应该可以ping通。 2. 扩展的访问列表 去掉刚才配置的访问列表和应用在接口的命令,即在原命令前加NO即可,注意命令的操作模式。 实验目的:不允许源IP是172.16.0.17的设备telnet p2r2 首先配置好允许telnet的准备工作:配置VTY密码。 设置访问列表(在p2r2上设置) access-list 100 deny ip host172.16.0.17 any eq 23 acess-list 100 permit ip any any 将ACL应用在p2r2的S0上: IP access-group 100 in 验证: 在p2r1上验证 telnet 2.2.2.2 ,应该被拒绝。 然后可以在p2r1的全局配置模式输入 ip telnet source-interface loopback0 这条命令把telnet的原接口地址改为LOOPBACK0的地址,重新 telnet 2.2.2.2 ,应该可以ping通。 3. 应用在VTY线路上的访问列表 删除刚才的配置. 设置访问列表(在p2r2上设置) 作者: 啥都不会 2006-1-9 09:26   回复此发言 -------------------------------------------------------------------------------- 4 我的ccna上机实验文档 access-list 1 permit 1.1.1.1 应用到VTY线路上。 Line vty 0 4 Access-class 1 in 验证: p2r1#telnet 2.2.2.2 (应该可以telnet成功,因为刚才的telnet源地址已经改成了loopback0) 再用ip telnet source-interface s0 再telnet 2.2.2.2 应该不成功。 配置HDLC和PPP协议 注:必须在广域网链路上配置。 1.配置PPP协议: 封装ppp即可 ping直连的邻居接口。 2.PAP单向认证配置实例: 验证方: router-server(config)# username Client password 12345 <--验证方建立数据库--> router-server(config)# interface serial 0 router-server(config-if)# encapsulation ppp router-server(config-if)# ppp authentication pap <--选择使用PAP实现PPP认证--> router-server(config-if)# ^z 被验证方: router-client(config-if)# encapsulation ppp router-client(config-if)# ppp pap sent-username Client password 12345 <--发送验证信息--> router-client(config-if)# ^z 3.PAP双向认证配置实例: 路由器 A: routerA(config)# username B password 12345 routerA(config)# interface serial 0 routerA(config-if)# encapsulation ppp routerA(config-if)# ppp authentication pap routerA(config-if)# ppp pap sent-username A password 54321 routerA(config-if)# ^z 路由器 B: routerB(config)# username A password 54321 routerB(config)# interface serial 1 routerB(config-if)# encapsulation ppp routerB(config-if)# ppp authentication pap routerB(config-if)# ppp pap sent-username B password 12345 routerB(config-if)# ^z 4.CHAP单向认证配置实例: 验证方: router-server(config)# username router-client password 12345 router-server(config)# interface serial 0 router-server(config-if)# encapsulation ppp router-server(config-if)# ppp authentication chap router-server(config-if)# ^z 被验证方: router-client(config-if)# encapsulation ppp router-client(config-if)# ppp chap hostname router-client router-client(config-if)# ppp chap password 12345 router-client(config-if)# ^z 5 .CHAP双向认证配置实例: 路由器 A: routerA(config)# username routerB password 12345 routerA(config)# interface serial 0 routerA(config-if)# encapsulation ppp routerA(config-if)# ppp authentication chap routerA(config-if)# ppp chap hostname routerA routerA(config-if)# ppp chap password 54321 routerA(config-if)# ^z 路由器 B: routerB(config)# username routerA password 54321 routerB(config)# interface serial 1 routerB(config-if)# encapsulation ppp routerB(config-if)# ppp authentication chap routerB(config-if)# ppp chap hostname routerB routerB(config-if)# ppp chap password 12345 routerB(config-if)# ^z 验证: debug ppp authentication 配置nat 拓扑图: 1. 静态nat转换 配置好路由器的IP地址和路由,shutdown如图某些端口,建立loopback0端口 P2R1 int loopback0 ip add 1.1.1.1 255.255.255.255 ip add 1.1.1.2 255.255.255.255 secondary ip add 1.1.1.3 255.255.255.255 secondary int s1 ip add 172.16.0.17 255.255.255.240 clock rate 64000(如果是DCE的话) no shut router rip network 1.0.0.0 network 172.16.0.0 P2R2 Int loopback 0 Ip add 2.2.2.2 255.255.255.255.255 Int s1 Ip add 172.16.0.18 255.255.255.240 No shut 作者: 啥都不会 2006-1-9 09:26   回复此发言 -------------------------------------------------------------------------------- 5 我的ccna上机实验文档 Router rip Network 2.0.0.0 Network 172.16.0.0 Sh ip route 应该可以验证到所有网段的路由. 然后在P2R1上做静态配置. Int s0 Ip nat outside Int loopback0 Ip nat inside P2r1(config)#ip nat inside static 1.1.1.1 172.16.0.19 验证:debug ip nat 用扩展的ping 选择1.1.1.1 作为ping的源地址,目的地址为P2R2的2.2.2.2 应该可以看到debug信息,如果是telnet到路由器上的可能看不到,这样的话用terminal monitor show ip nat translation可以看静态的转换条目在nat表里面. 2. 动态nat转换 不做复用的nat,需要设置多个源地址,这就是为什么我们给loopback设置多个IP的原因,然后要设置pool. 目的是不做复用的nat转换,如果地址池地址不够,就会发生转换不了的现象. 去除刚才做静态的nat转换 no ip nat inside static 1.1.1.1 172.16.0.19 设置地址池(inside global) ip nat pool tyl 172.16.0.19 172.16.0.20 netmask 255.255.255.240 设置inside local access-list 1 permit 1.1.1.1 access-list 1 permit 1.1.1.2 access-list 1 permit 1.1.1.3 配置nat转换 ip nat inside source list 1 pool tyl 用扩展的ping做验证: 分别选用1.1.1.1 ;1.1.1.2;1.1.1.1.3作为源IP地址,目的地址2.2.2.2,因为地址池只有两个IP,这样第三个转换应该不成功. Debug ip nat Sh ip nat translation 3. 动态nat转换overload 为解决刚才的问题,我们可以才用pat,也就是nat的overload技术 去除刚才的转换 no ip nat inside source list 1 pool tyl ip nat inside source list 1 pool tyl overload or 按教材上的做法直接在接口上进行复用. 这样还用扩展的ping做验证,三次转换都应该成功才对. 帧中继实验 本实验配置只供实验室只有两台路由器时做模拟用,如上图所示,router1作为帧中继交换机,router2作为本地路由器. Router 1 frame-relay switching !--- Allows this router to function (frame-relay switching - Enables PVC switching on a FR DCE device or a network-to-network interface. ) (frame-relay intf-type dce - Configures the FR switch type. A router or an access server functions as a switch connected to a router.) !--- as a FRswitch. interface Serial0 ip address 172.16.0.17 255.255.255.240 encapsulation frame-relay frame-relay map ip 172.16.0.18 101 broadcast !--- The data-link connection identifiers(DLCIs) !--- configured in the map statements must match. clock rate 64000 frame-relay intf-type dce !--- This command specifies the !--- interface to handle LMI like a FR DCE device. ! Router 2 Interface Serial0 ip address 172.16.0.18 255.255.255.240 encapsulation frame-relay frame-relay map ip 172.16.0.17 101 broadcast !--- The DLCIs configured in the map !--- statements must match. 验证: show frame-relay pvc show frame-relay lmi