实验
拓扑图:
步骤:
一,使用VPCS配置各PC机的IP地址:
二,在各路由器上配置IP地址和路由协议
R1:
R1(config)#int f0/0
R1(config-if)#ip add 192.168.20.2 255.255.255.0
R1(config-if)#no shut
R1(config)#int f0/1
R1(config-if)#ip add 192.168.30.1 255.255.255.0
R1(config-if)#no shut
R1(config-router)#int loo 0
R1(config-if)#ip add 1.1.1.1 255.255.255.255
R1(config-if)#no shut
R1(config)#router ospf 1
R1(config-router)#router
R1(config-router)#router-id 1.1.1.1
R1(config-router)#net
R1(config-router)#network 1.1.1.1 0.0.0.0 area 1
R1(config-router)#network 192.168.30.0 0.0.0.255 area 1
R1(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1
R2:
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int f0/0
R2(config-if)#ip add 192.168.30.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#no sw
R2(config-if)#no switchport
R2(config-if)#ip add 192.168.40.1 255.255.255.0
R2(config-if)#no shut
R2(config-if)#no swi
R2(config-if)#no switchport
R2(config-if)#
*Mar 1 00:30:41.303: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to down
R2(config-if)#ip add
*Mar 1 00:30:43.479: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/1, changed state to up
R2(config-if)#ip add 192.168.70.1 255.255.255.0
R2(config-if)#no shut
R2(config-if)#int f0/1
R2(config-if)#ip add 20.0.0.1 255.255.255.0
R2(config-if)#no shut
R2(config-if)#no shut
R2(config-if)#int loo 0
R2(config-if)#ip addd
*Mar 1 00:35:18.499: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
R2(config-if)#ip add 2.2.2.2 255.255.255.255
R2(config-if)#no shut
R2(config)#router ospf 1
R2(config-router)#router
R2(config-router)#router-id 2.2.2.2
R2(config-router)#net
R2(config-router)#network 192.168.30.0 0.0.0.255 area 1
R2(config-router)#network 192.168.30.0 0.0.0.255 area 0
*Mar 1 00:37:29.395: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on FastEthernet0/0 from LOADING to FULL, Loading Done
R2(config-router)#network 192.168.40.0 0.0.0.255 area 0
R2(config-router)#network 2.2.2.2 0.0.0.0 area 0
R2(config-router)#network 192.168.70.0 0.0.0.255 area 0
R2(config-router)#ex
R2(config)#ip route 0.0.0.0 0.0.0.0 20.0.0.2
R3:
R3(config)#int f0/0
R3(config-if)#ip add 20.0.0.2 255.255.255.0
R3(config-if)#no shut
R3(config-if)#int f0/1
R3(config-if)#ip add 10.0.0.1 255.255.255.0
R3(config-if)#no shut
R3(config)#ip route 0.0.0.0 0.0.0.0 20.0.0.1 255.255.255.0
R4:
R4(config)#int f0/0
R4(config-if)#ip add 192.168.20.1 255.255.255.0
R4(config-if)#no shut
R4(config-if)#int f0/1
R4(config-if)#ip add 192.168.10.1 255.255.255.0
R4(config-if)#no shut
R4(config-if)#ex
R4(config)#ip route 0.0.0.0 0.0.0.0 192.168.20.2
R5:
R5(config)#int f0/0
R5(config-if)#ip add 192.168.40.2 255.255.255.0
R5(config-if)#no shut
R5(config-if)#int f0/1
R5(config-if)#ip add 192.168.50.1 255.255.255.0
R5(config-if)#no shut
R5(config-if)#int loo 0
R5(config-if)#ip add
*Mar 1 00:49:53.503: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
R5(config-if)#ip add 5.5.5.5 255.255.255.255
R5(config-if)#no shut
R5(config-if)#ex
R5(config)#router ospf 1
R5(config-router)#router
R5(config-router)#router-id 5.5.5.5
R5(config-router)#net
R5(config-router)#network 192.168.40.0 0.0.0.255 area 0
R5(config-router)#
*Mar 1 00:52:23.475: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0 from LOADING to FULL, Loading Done
R5(config-router)#net
R5(config-router)#network 5.5.5.5 0.0.0.0 area 0
R5(config-router)#ex
R5(config)#router rip
R5(config-router)#ver
R5(config-router)#version 2
R5(config-router)#no
R5(config-router)#no au
R5(config-router)#no auto-summary
R5(config-router)#net
R5(config-router)#network 192.168.50.0
R5(config-router)#net
R5(config-router)#network 1.1.1.1
R6:
R6(config)#int f0/0
R6(config-if)#ip add 192.168.50.2 255.255.255.0
R6(config-if)#no shut
R6(config-if)#int f0
R6(config-if)#int f0/1
R6(config-if)#ip add 192.168.60.1 255.255.255.0
R6(config-if)#no shut
R6(config-if)#
R6(config-if)#ex
R6(config)#router rip
R6(config-router)#ver
R6(config-router)#version 2
R6(config-router)#no au
R6(config-router)#no auto-summary
R6(config-router)#net
R6(config-router)#network 192.168.50.0
R6(config-router)#network 192.168.60.0
二,在各路由器上做路由重分发
R1:
R1(config)#router ospf 1
R1(config-router)#re
R1(config-router)#redistribute st
R1(config-router)#redistribute static m
R1(config-router)#redistribute static sub
R1(config-router)#redistribute static subnets
R1(config-router)#re
R1(config-router)#redistribute co
R1(config-router)#redistribute connected su
R1(config-router)#redistribute connected subnets
R2:
R2(config-router)#re
R2(config-router)#redistribute ci
R2(config-router)#redistribute con
R2(config-router)#redistribute connected su
R2(config-router)#redistribute connected subnets
R2(config-router)#defa
R2(config-router)#default-in
R2(config-router)#default-information ori
R2(config-router)#default-information originate
R5:
R5(config)#router ospf 1
R5(config-router)#re
R5(config-router)#redistribute rip su
R5(config-router)#redistribute rip subnets
R5(config-router)#ex
R5(config)#router rip
R5(config-router)#re
R5(config-router)#redistribute ospf 1 me
R5(config-router)#redistribute ospf 1 metric 3
三,R2作为出口路由器需要做NAT地址转换
R2:
R2(config)#access-list 1 per
R2(config)#access-list 1 permit 192.168.0.0 0.0.255.255
R2(config)#ip nat insi
R2(config)#ip nat inside source
R2(config)#ip nat inside source list 1 int f0/1 over
R2(config)#ip nat inside source list 1 int f0/1 overload
R2(config)#int f0/0
R2(config-if)#ip nat in
R2(config-if)#ip nat inside
R2(config-if)#int f1/0
R2(config-if)#ip nat in
R2(config-if)#ip nat inside
R2(config-if)#int f1/1
R2(config-if)#ip nat in
R2(config-if)#ip nat inside
R2(config-if)#int f0/1
R2(config-if)#ip nat out
R2(config-if)#ip nat outside
使用debug命令验证:
C1:
*Mar 1 01:24:47.607: NAT: s=192.168.10.10->20.0.0.1, d=10.0.0.10 [63830]
R2#
*Mar 1 01:24:49.627: NAT*: s=192.168.10.10->20.0.0.1, d=10.0.0.10 [63831]
R2#
*Mar 1 01:24:51.735: NAT*: s=192.168.10.10->20.0.0.1, d=10.0.0.10 [63832]
*Mar 1 01:24:51.783: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.10.10 [63832]
R2#
*Mar 1 01:24:53.043: NAT*: s=192.168.10.10->20.0.0.1, d=10.0.0.10 [63833]
*Mar 1 01:24:53.143: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.10.10 [63833]
C2:
R2#
*Mar 1 01:26:21.919: NAT*: s=192.168.60.10->20.0.0.1, d=10.0.0.10 [63926]
*Mar 1 01:26:22.043: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.60.10 [63926]
R2#
*Mar 1 01:26:23.131: NAT*: s=192.168.60.10->20.0.0.1, d=10.0.0.10 [63927]
*Mar 1 01:26:23.183: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.60.10 [63927]
R2#
*Mar 1 01:26:24.371: NAT*: s=192.168.60.10->20.0.0.1, d=10.0.0.10 [63928]
*Mar 1 01:26:24.511: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.60.10 [63928]
R2#
*Mar 1 01:26:25.663: NAT*: s=192.168.60.10->20.0.0.1, d=10.0.0.10 [63929]
*Mar 1 01:26:25.779: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.60.10 [63929]
R2#
*Mar 1 01:26:26.931: NAT*: s=192.168.60.10->20.0.0.1, d=10.0.0.10 [63930]
*Mar 1 01:26:27.027: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.60.10 [63930]
C3:
*Mar 1 01:27:58.959: NAT*: s=192.168.70.10->20.0.0.1, d=10.0.0.10 [64023]
*Mar 1 01:27:59.091: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.70.10 [64023]
R2#
*Mar 1 01:28:00.163: NAT*: s=192.168.70.10->20.0.0.1, d=10.0.0.10 [64024]
*Mar 1 01:28:00.279: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.70.10 [64024]
R2#
*Mar 1 01:28:01.387: NAT*: s=192.168.70.10->20.0.0.1, d=10.0.0.10 [64025]
*Mar 1 01:28:01.655: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.70.10 [64025]
R2#
*Mar 1 01:28:02.711: NAT*: s=192.168.70.10->20.0.0.1, d=10.0.0.10 [64026]
*Mar 1 01:28:02.743: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.70.10 [64026]
R2#
*Mar 1 01:28:03.883: NAT*: s=192.168.70.10->20.0.0.1, d=10.0.0.10 [64027]
*Mar 1 01:28:04.003: NAT*: s=10.0.0.10, d=20.0.0.1->192.168.70.10 [64027]
验证全网互通:
实验完成
本文出自 “共同努力,共同进步~~” 博客,请务必保留此出处http://9067358.blog.51cto.com/9057358/1605922
原文地址:http://9067358.blog.51cto.com/9057358/1605922