2008三层交换与路由综合配置.pdf
1 2 作者:红盟过客CCIE 理论 RHCE QQ :369136929 msn : 籍贯 :湖北宜昌。 有宜昌的朋友可以一起聊聊技术。 杭州CCIE 联盟群 40576311 时间:2008 年七月 地点:浙江杭州 软件:Visio 2007 CorelDRAW 12WPS 2005 说明:一般情况下三台路由器。模拟器为原版的 Dynamipsi 顺序:R1 的 F0/0 接 R2的 F0/0 ,R2 的 F1/1 接 R3 的 F1/1。在这里用 lookback 接口来 模拟不同网段。路由器都为最小配置 cisco2501.IOS 是 12.0 以上。提醒一下:现在可以用 Dynamips软件完全模拟所有的实验。为了使实验更有价值, 所写实验均在真实路由器上完 成。 已完成的实验手册 2008 vpn自学命令与配置手册 第一版 2008 ospf 命令与配置手册实验笔记第二版 2008 bgp 命令与配置手册实验笔记第二版 2009 ISIS 命令与配置手册实验笔记 第一版 2008 三层交换与路由综合配置案例 RHCE5.0 实验手册 华为 3600 交换机实验笔记 BGP 设计与实现笔记 JUNIPER NETSCREEN 防火墙基础实验 杭州某中学断网解决办法 模拟器配置,直接可以用。 # Simple lab 3 autostart=False localhost 7200 image=D:路由器 7200.bin# Full path to 7200 IOS image file. This is the fullyqualified path relative to the system runningdynamips. ram=128# Amount of Virtual RAM to allocate to each router instance nvram=96# Size of NVRAM disk0=64# Set size of PCMCIA ATA disk0 disk1=64# Set size of PCMCIA ATA disk1 cnfg=None# Configuration file to import. This is the fully qualified path relative to the system runningdynamips. confreg=0 x2102# Set the configuration register clock=2# Clock divisor (should no longer been needed as of dynamips 0.2.5 RC1) mmap=True# Set to false to use real memory rather than a disk file for router vitural memory. Conserves RAM at the expense of performance. Defaultsto True exec_area=64# Set the exec area size ROUTER r1 model=7200 f2/0=NIO_gen_eth:DeviceNPF_CA4642AB-4C39-4131-9968- B653B0C61FD8 #s1/0=r2 s1/0 f0/0=r2 f0/13 idlepc=0 x6072d4b4 ROUTER r2 model=3640 console=2001 image=D:路由器3640.bin slot0=NM-16ESW注意这里是 16 个交换端口 f0/14=r3 f0/0 f0/15=r4 f0/0 idlepc=0 x604ec6d8 #f0/0=r3 f0/0 #s1/1=r3 s1/1 4 #idlepc=0 xffffffff80009f94 ROUTER r3 model=7200 #f2/0=r4 f2/0 #s1/0=r4 s1/0 idlepc=0 xffffffff8000ae84 ROUTER r4 model=7200 idlepc=0 x6072d2dc #f0/0=r5 f0/0 要求: 分三个 vlan,vlan2,vlan3 vlan 100.Vlan100与路器通信,vlan2 网关为 192.168.2.1 vlan3 为 192.168.3.1 vlan100 为 192.168.1.1,路由器 f0/0 接口为 192.168.1.1 。 怎么配置才能让 pc1pc2 能与外网通信。路由器配置与外网认为以配置好. 配置命令 r1(config)#int f0/0 r1(config-if)#no sh r1(config-if)#du fu r1(config-if)#ip add 192.168.1.1 255.255.255.0 r1(config-if)#no sh r1(config-if)#end r1(config)#int lo0 r1(config-if)#ip add 1.1.1.1 255.255.255.0 r1(config-if)#no sh r1(config-if)#end 配置 vlan,将端口分入 vlan r2#vlan da r2(vlan)#vlan 100 name 100 VLAN 100 added: Name: 100 r2(vlan)#vlan 2 name 2 VLAN 2 modified: Name: 2 r2(vlan)#vlan 3 name 3 VLAN 3 added: 5 Name: 3 r2(vlan)#exit APPLY completed. Exiting. r2(config)#int vlan 100 r2(config-if)#ip add 192.168.1.2 255.255.255.0 r2(config-if)#no sh r2(config-if)#int vlan 2 r2(config-if)#no sh r2(config-if)#ip add 192.168.2.1 255.255.255.0 r2(config-if)#int vlan 3 r2(config-if)#ip add 192.168.3.1 255.255.255.0 r2(config-if)#no sh r2(config-if)#end r2(config)#int f0/13 r2(config-if)#no sh r2(config-if)#du fu r2(config-if)#sp 100 r2(config-if)#swi mode acc r2(config-if)#swi acc vlan 100 r2(config-if)#end r2(config)#int f0/14 r2(config-if)#no sh r2(config-if)#du fu r2(config-if)#sp 100 r2(config-if)#swi mode acc r2(config-if)#swi acc vlan 2 r2(config-if)#int f0/15 r2(config-if)#no sh r2(config-if)#du fu r2(config-if)#sp 100 r2(config-if)#swi mode acc r2(config-if)#swi acc vlan 3 r2(config-if)#end R3 模拟 pc,注意去路由功能,还有设置网关,地址。 r3(config)#no ip routi r3(config)#int f0/0 r3(config-if)#no sh r3(config-if)#du fu 6 r3(config-if)#ip add 192.168.2.2 255.255.255.0 r3(config-if)#end r3(config)#ip default-g192.168.2.1 r4(config)#no ip routi r4(config)#int f0/0 r4(config-if)#no sh r4(config-if)#du fu r4(config-if)#ip add 192.168.3.2 255.255.255.0 r4(config-if)#no sh r4(config-if)#end r4(config)#ip default-g192.168.3.1 在这里设置完成,但是能 ping通网关 ping 不通对 vlan2 的主机,原因没有打开交换机的 路由功能。在高端交换机,路由功能是默认打开,但是 35 等是关闭。手工打开。 r4#ping 192.168.2.1 Type escape sequence to abort. Sending5, 100-byte ICMP Echos to 192.168.2.1, timeout is2 seconds: ! Success rate is 100 percent(5/5), round-trip min/avg/max= 8/24/40 ms r4#ping 192.168.2.2 Type escape sequence to abort. Sending5, 100-byte ICMP Echos to 192.168.2.2, timeout is2 seconds: . Success rate is 0 percent (0/5) r2(config)#ip routi 路由功能打开,可以 ping通 vlan主机。 r4#ping 192.168.2.2 Type escape sequence to abort. Sending5, 100-byte ICMP Echos to 192.168.2.2, timeout is2 7 seconds: ! Success rate is 100 percent(5/5), round-trip min/avg/max= 8/34/68 ms 但是 ping不通路由器的地址。因为交换机没有到达路由器的路由。 r4#ping 192.168.1.1 Type escape sequence to abort. Sending5, 100-byte ICMP Echos to 192.168.1.1, timeout is2 seconds: . Success rate is 0 percent (0/5) 设置到达路由器的静态路由。 r2(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1 r2(config)#end 设置路由器到达交换机的两条回程路由。不然,pc 直能有去的路由,没有回来的路由。仍 然不通。 r1#conf t r1(config)#ip route 192.168.2.0 255.255.255.0 192.168.1.2 r1(config)#ip route 192.168.3.0 255.255.255.0 192.168.1.2 r1(config)#end r4#ping 192.168.1.1 Type escape sequence to abort. Sending5, 100-byte ICMP Echos to 192.168.1.1, timeout is2 seconds: ! Success rate is 100 percent(5/5), round-trip min/avg/max= 16/38/60 ms r4#ping 1.1.1.1 Type escape sequence to abort. Sending5, 100-byte ICMP Echos to 1.1.1.1, timeout is2 8 seconds: ! Success rate is 100 percent(5/5), round-trip min/avg/max= 32/54/68 ms 在这个实验中,两点应当注意,就是交换机与路由器上的几个静态路由。当然,路由器要与 外面通信,还要配置接口地址,还要配置 nat。三层交换机不能直接与外网通信的一个主要 问题就是不支持 nat。 路由器与三层交换机的精典配置案例 2 第一步先配置 r5 与 r1 相互通信 r5(config)#int s1/0 r5(config-if)#no sh r5(config-if)#ip add 1.1.1.1 255.255.255.0 r5(config-if)#no sh r5(config-if)#end r1(config)#int s1/0 r1(config-if)#no sh r1(config-if)#ip add 1.1.1.2 255.255.255.0 r1(config-if)#no sh r1(config-if)#ip nat outside 9 r1(config)#int f0/0 r1(config-if)#no sh r1(config-if)#ip add 192.168.1.1 255.255.255.0 r1(config-if)#ip nat inside r1(config-if)#du fu r2(config)#int f0/13 r2(config-if)#no sh r2(config-if)#no swi r2(config-if)#ip add 192.168.1.2 255.255.255.0 r2(config-if)#exit r2(config)#exit r2#vlan da r2(vlan)#vlan 10 name 10 VLAN 10 added: Name: 10 r2(vlan)#vlan 20 name 20 VLAN 20 added: Name: 20 r2(vlan)#exit r2(config)#int vlan 10 r2(config-if)#no sh r2(config-if)#ip add 192.168.10.1 255.255.255.0 r2(config-if)#int vlan 20 r2(config-if)#ip add 192.168.20.1 255.255.255.0 r2(config-if)#exit r2(config)#int f0/14 r2(config-if)#no sh r2(config-if)#int f0/15 r2(config-if)#swi mode acc r2(config-if)#swi acc vlan 20 r2(config-if)#no sh r2(config-if)#end r2(config)#ip default-g192.168.1.1 设置默认网关 r2(config)#ip routi打开三层路由。 r3(config)#int f0/0 r3(config-if)#no sh r3(config-if)#ip add 192.168.10.2 255.255.255.0 10 r3(config-if)#end r3(config)#no ip routi r3(config)#end r3(config)#ip default-g192.168.10.1 模拟 pc 的网关 r3(config)#end r4(config)#int f0/0 r4(config-if)#no sh r4(config-if)#ip add 192.168.20.2 255.255.255.0 r4(config-if)#no sh r4(config-if)#end r4(config)#no ip routi r4(config)#ip default-g192.168.20.1 r2(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1 能访问外网的路由 r4#ping 192.168.1.1 Type escape sequence to abort. Sending5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: . Success rate is 0 percent (0/5) r1(config)#ip route 192.168.0.0 255.255.0.0 192.168.1.2路由的回程路由。 r4#ping 192.168.1.1 Type escape sequence to abort. Sending5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds: ! Success rate is 100 percent(5/5), round-trip min/avg/max =32/81/128 ms r4#ping 1.1.1.2 Type escape sequence to abort. Sending5, 100-byte ICMP Echos to 1.1.1.2, timeout is2 11 seconds: ! Success rate is 100 percent(5/5), round-trip min/avg/max =32/66/96 ms r4#ping 1.1.1.1 Type escape sequence to abort. Sending5, 100-byte ICMP Echos to 1.1.1.1, timeout is2 seconds: . Success rate is 0 percent (0/5) 做 nat能访问外网。 r1(config)#access-list 101 permit ip 192.168.0.0 0.0.255.255 any 限制那些主机能访问外网 端口转换 r1(config)#ip nat source list 101 interface s1/0 overload *Jan 14 18:43:54.659: %SYS-2-MALLOCFAIL: Memory allocation of 3000 bytes failed from 0 x6141B704, alignment 0 Pool: ProcessorFree: 10716Cause: Memory fragmentation Alternate Pool: NoneFree: 0Cause: No Alternate pool -Process= Exec, ipl= 0, pid= 72 -Traceback= 0 x613D2874 0 x6000AF3C0 x60012254 0 x63379A84 0 x6141B70C 0 x60371EEC 0 x603703B0 0 x6036F548 0 x6036F5F0 0 x60369048 0 x603688B8 0 x61414408 0 x6141607C 0 x614355FC0 x62987F80 0 x62987F64