赞
踩
实验涉及知识点:
vlan规划,单臂路由子接口,rip与ospf使用与重分布,默认路由注入、NAT
设备需求:
路由器*7
三层交换机*1
二层交换机*2
PC*4
实验拓扑图:
实验结果:
所有计算机可以与27.27.27.2通信,pc0可以与pc3通信
实验任务:
路由器配置:
R1、R2之间运行RIPv2协议
R3g0/1接口发布至ripv2,g0/0发布至ospf的区域0
R4、R5、R6之间运行ospf协议,其中R4,R5发布至区域0,R5的g0/0接口与R6发布至区域1
R3配置nat协议,所有内网ip转换为网段27.27.27.0/24
各路由器和三层交换机等设备配置回环地址,ip地址,vlan划分详情见下
路由器配置表
设备名称 | 接口 | IP地址 |
R1 | g0/1 | 11.11.11.2/24 |
R1 | g0/0 | 12.12.12.1/24 |
R2 | g0/0 | 12.12.12.2/24 |
R2 | g0/1 | 23.23.23.1/24 |
R3 | g0/1 | 23.23.23.2/24 |
R3 | g0/0 | 34.34.34.1/24 |
R3 | g0/2 | 27.27.27.1/24 |
R4 | g0/0 | 34.34.34.2/24 |
R4 | g0/1 | 45.45.45.1/24 |
R5 | g0/1 | 45.45.45.2/24 |
R5 | g0/0 | 56.56.56.1/24 |
R6 | g0/0 | 56.56.56.2/24 |
R6 | g0/1.10 | 172.16.10.1/24 |
R6 | g0/1.20 | 172.16.20.1/24 |
R7 | g0/2 | 27.27.27.2/24 |
路由器回环地址配置
设备名称 | 路由器回环地址 |
R1 | 1.1.1.1/32 |
R2 | 2.2.2.2/32 |
...... | ...... |
R7 | 7.7.7.7/32 |
S1 | 101.1.1.1/32 |
交换机配置
设备名称 | 配置要求 |
S0 | f0/10-vlan10 f0/20-vlan20 |
S1 | vlan10--192.168.10.1/24 vlan20--192.168.20.1/24 |
S2 | f0/2-vlan10 f0/3-vlan20 |
- Router>enable
- Router#configure terminal
- Router(config)#hostname R1
- R1(config)#interface g0/1
- R1(config-if)#no shutdown
- R1(config-if)#ip address 11.11.11.2 255.255.255.0
- R1(config-if)#interface g0/0
- R1(config-if)#no shutdown
- R1(config-if)#ip address 12.12.12.1 255.255.255.0
- ------------------
- Router>
- Router>enable
- Router#conf t
- Router(config)#hostname R2
- R2(config)#interface g0/0
- R2(config-if)#no shutdown
- R2(config-if)#ip address 12.12.12.2 255.255.255.0
- R2(config-if)#interface g0/1
- R2(config-if)#no shutdown
- R2(config-if)#ip address 23.23.23.1 255.255.255.0
- ------------------------
- //剩余的ip地址部分以此类推
- Router>enable
- Router#configure terminal
- Router(config)#hostname R6
- R6(config)#interface g0/0
- R6(config-if)#no shutdown
- R6(config-if)#ip address 56.56.56.2 255.255.255.0
- R6(config-if)#interface g0/1.10
- R6(config-subif)#encapsulation dot1q 10#封装子接口vlanid为10
- R6(config-subif)#ip address 172.16.10.1 255.255.255.0
- R6(config-subif)#no shutdown
- R6(config-subif)#int g0/1.20
- R6(config-subif)#no shutdown
- R6(config-subif)#encapsulation dot1q 20#封装子接口vlanid为20
- R6(config-subif)#ip add 172.16.20.1 255.255.255.0
- R6(config-subif)#int g0/1
- R6(config-if)#no shutdown
- R1(config)#interface loopback 0
- R1(config-if)#ip address 1.1.1.1 255.255.255.255
- #回环地址的网络掩码为32位
- .....
- R7(config)#interface loopback 0
- R7(config-if)#ip address 7.7.7.7 255.255.255.255
- #RIPv2配置部分
- R1(config)#router rip
- R1(config-router)#version 2
- R1(config-router)#no auto
- R1(config-router)#no auto-summary
- R1(config-router)#network 11.11.11.0
- R1(config-router)#network 12.12.12.0
- #---------------
- R2(config)#router rip
- R2(config-router)#version 2
- R2(config-router)#no auto-summary
- R2(config-router)#network 12.12.12.0
- R2(config-router)#network 23.23.23.0
- #-------------------
- R3(config)#router rip
- R3(config-router)#version 2
- R3(config-router)#no auto-summary
- R3(config-router)#network 23.23.23.0
- #---------------------
- #------------------
- #OSPF配置部分
- R3(config)#router ospf 1
- R3(config-router)#network 34.34.34.0 0.0.0.255 area 0
- #------------------
- R4(config)#router ospf 1
- R4(config-router)#network 34.34.34.0 0.0.0.255 area 0
- R4(config-router)#network 45.45.45.0 0.0.0.255 area 0
- #-------------------
- R5(config)#router ospf 1
- R5(config-router)#network 45.45.45.0 0.0.0.255 area 0
- R5(config-router)#network 56.56.56.0 0.0.0.255 area 1#注意发布区域
- #--------------
- R6(config)#router ospf 1
- R6(config-router)#network 56.56.56.0 0.0.0.255 area 1
- R6(config-router)#network 172.16.0.0 0.0.255.255 area 1
- #此时R1路由表
- R1#show ip route
- Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
- D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
- N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
- E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
- i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
- * - candidate default, U - per-user static route, o - ODR
- P - periodic downloaded static route
-
- Gateway of last resort is not set
-
- 1.0.0.0/32 is subnetted, 1 subnets
- C 1.1.1.1/32 is directly connected, Loopback0
- 11.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
- C 11.11.11.0/24 is directly connected, GigabitEthernet0/1
- L 11.11.11.2/32 is directly connected, GigabitEthernet0/1
- 12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
- C 12.12.12.0/24 is directly connected, GigabitEthernet0/0
- L 12.12.12.1/32 is directly connected, GigabitEthernet0/0
- 23.0.0.0/24 is subnetted, 1 subnets
- R 23.23.23.0/24 [120/1] via 12.12.12.2, 00:00:10, GigabitEthernet0/0
- #此时R6路由表
- R6#
- %SYS-5-CONFIG_I: Configured from console by console
- show ip route
- Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
- D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
- N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
- E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
- i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
- * - candidate default, U - per-user static route, o - ODR
- P - periodic downloaded static route
-
- Gateway of last resort is not set
-
- 6.0.0.0/32 is subnetted, 1 subnets
- C 6.6.6.6/32 is directly connected, Loopback0
- 34.0.0.0/24 is subnetted, 1 subnets
- O IA 34.34.34.0/24 [110/3] via 56.56.56.1, 00:03:09, GigabitEthernet0/0
- #另一区域的路由
- 45.0.0.0/24 is subnetted, 1 subnets
- O IA 45.45.45.0/24 [110/2] via 56.56.56.1, 00:03:09, GigabitEthernet0/0
- 56.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
- C 56.56.56.0/24 is directly connected, GigabitEthernet0/0
- L 56.56.56.2/32 is directly connected, GigabitEthernet0/0
- 172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks
- C 172.16.10.0/24 is directly connected, GigabitEthernet0/1.10
- L 172.16.10.1/32 is directly connected, GigabitEthernet0/1.10
- C 172.16.20.0/24 is directly connected, GigabitEthernet0/1.20
- L 172.16.20.1/32 is directly connected, GigabitEthernet0/1.20
- #RIPv2重分布
- R3(config)#router rip
- R3(config-router)#redistribute ospf 1 metric 2
- #将R3上ospf 1 的路由条目重分布至rip中
配置完成后在R1执行“show ip route"将可以看到以下路由条目
- 34.0.0.0/24 is subnetted, 1 subnets
- R 34.34.34.0/24 [120/3] via 12.12.12.2, 00:00:08, GigabitEthernet0/0
- 45.0.0.0/24 is subnetted, 1 subnets
- R 45.45.45.0/24 [120/3] via 12.12.12.2, 00:00:08, GigabitEthernet0/0
- 56.0.0.0/24 is subnetted, 1 subnets
- R 56.56.56.0/24 [120/3] via 12.12.12.2, 00:00:08, GigabitEthernet0/0
- 172.16.0.0/24 is subnetted, 2 subnets
- R 172.16.10.0/24 [120/3] via 12.12.12.2, 00:00:08, GigabitEthernet0/0
- R 172.16.20.0/24 [120/3] via 12.12.12.2, 00:00:08, GigabitEthernet0/0
rip重分布配置完成。
- #OSPF重分布
- R3(config)#router ospf 1
- R3(config-router)#redistribute rip subnets
- R3(config-router)#redistribute rip metric 2
配置完成后在R6执行”show ip route"可以看到以下路由条目
- O E2 11.11.11.0/24 [110/2] via 56.56.56.1, 00:00:10, GigabitEthernet0/0
- 12.0.0.0/24 is subnetted, 1 subnets
- O E2 12.12.12.0/24 [110/2] via 56.56.56.1, 00:00:10, GigabitEthernet0/0
- 23.0.0.0/24 is subnetted, 1 subnets
- O E2 23.23.23.0/24 [110/2] via 56.56.56.1, 00:00:10, GigabitEthernet0/0
- 34.0.0.0/24 is subnetted, 1 subnets
- O IA 34.34.34.0/24 [110/3] via 56.56.56.1, 00:07:57, GigabitEthernet0/0
- 45.0.0.0/24 is subnetted, 1 subnets
- O IA 45.45.45.0/24 [110/2] via 56.56.56.1, 00:07:57, GigabitEthernet0/0
- #O E2表示重分布的路由
- #O IA表示非本区域的路由
OSPF重分布配置完成
RIP默认路由注入
- R3(config)#ip route 0.0.0.0 0.0.0.0 27.27.27.2
- #先写一个R3的默认路由
- R3(config)#router rip
- R3(config-router)#default-information originate
- #向使用RIP协议的路由器注入默认路由
配置完成后,可以在R1路由表发现以下条目
- R* 0.0.0.0/0 [120/2] via 12.12.12.2, 00:00:19, GigabitEthernet0/0
- #默认路由的概念是当路由器不知道转发给谁时就会按照默认路由转发给下一跳
OSPF默认路由注入
- R3(config)#router ospf 1
- R3(config-router)#default-information originate
配置完成后可以在R6路由表发现以下条目
O*E2 0.0.0.0/0 [110/1] via 56.56.56.1, 00:00:07, GigabitEthernet0/0
- R3(config)#access-list 10 permit any
- #所有主机都将被转换
- R3(config)#ip nat pool pool_all 27.27.27.10 27.27.27.254 netmask 255.255.255.0
- #创建转换池,pool_all是转换池的名称,转换范围是10-254(动态nat)
-
- #---------------#
- R3(config)#interface g0/2
- R3(config-if)#ip nat outside
- R3(config-if)#interface g0/1
- R3(config-if)#ip nat inside
- R3(config-if)#interface g0/0
- R3(config-if)#ip nat inside
- #g0/2外网接口,g0/0-1内网接口
- #---------------#
-
- R3(config-if)#exit
- R3(config)#ip nat inside source list 10 pool pool_all
- #将acl表与转换池绑定
路由器部分配置完毕
- Switch>enable
- Switch#configure terminal
- Switch(config)#hostname S0
- S0(config)#vlan 10
- S0(config-vlan)#vlan 20
- S0(config-vlan)#exit
- S0(config)#interface f0/2
- S0(config-if)#switchport mode trunk
- S0(config-if)#exit
- S0(config)#interface f0/10
- S0(config-if)#switchport access vlan 10
- S0(config-if)#interface f0/20
- S0(config-if)#switchport access vlan 20
- Switch>enable
- Switch#configure terminal
- Switch(config)#hostname S1
- S1(config)#vlan 10
- S1(config-vlan)#vlan 20
- S1(config-vlan)#exit
- S1(config)#interface loopback 0
- S1(config-if)#ip address 101.1.1.1 255.255.255.255#配置回环地址
- S1(config-if)#exit
- S1(config)#interface vlan 10
- S1(config-if)#no shutdown
- S1(config-if)#ip address 192.168.10.1 255.255.255.0
- S1(config-if)#interface vlan 20
- S1(config-if)#no shutdown
- S1(config-if)#ip address 192.168.20.1 255.255.255.0
- S1(config-if)#exit
- S1(config)#interface range f0/2
- S1(config-if-range)#switchport trunk encapsulation dot1q#封装协议
- S1(config-if-range)#switchport mode trunk
- S1(config)#ip routing#打开三层功能
- S1(config)#int f0/1
- S1(config-if)#no switchport #成为三层路由接口
- S1(config-if)#ip add 11.11.11.1 255.255.255.0
- S1(config-if-range)#exit
- S1(config)#router rip
- S1(config-router)#version 2
- S1(config-router)#no auto-summary
- S1(config-router)#network 11.11.11.0
- S1(config-router)#network 192.168.10.0
- S1(config-router)#network 192.168.20.0
- Switch>enable
- Switch#configure terminal
- Switch(config)#hostname S2
- S2(config)#interface f0/1
- S2(config-if)#switchport mode trunk
- S2(config-if)#vlan 10
- S2(config-vlan)#vlan 20
- S2(config-vlan)#interface f0/2
- S2(config-if)#switchport access vlan 10
- S2(config-if)#int f0/3
- S2(config-if)#switchport acces vlan 20
交换机配置完成
测试之前,请确保pc机按照以下配置完成并检查接口
设备名称 | ip地址 | 网关 |
pc0 | 192.168.10.2/24 | 192.168.10.1 |
pc1 | 192.168.20.2/24 | 192.168.20.1 |
pc2 | 172.16.10.2/24 | 172.16.10.1 |
pc3 | 172.16.20.2/24 | 172.16.20.1 |
pc0tracert-》pc3
成功
NAT测试
- R3#show ip nat translations
- Pro Inside global Inside local Outside local Outside global
- icmp 27.27.27.10:29 192.168.10.2:29 27.27.27.2:29 27.27.27.2:29
- icmp 27.27.27.10:30 192.168.10.2:30 27.27.27.2:30 27.27.27.2:30
- icmp 27.27.27.10:31 192.168.10.2:31 27.27.27.2:31 27.27.27.2:31
- icmp 27.27.27.10:32 192.168.10.2:32 27.27.27.2:32 27.27.27.2:32
- udp 27.27.27.11:1025 27.27.27.1:1025 255.255.255.255:53 255.255.255.255:53
NAT配置成功
目的达成,实验完毕
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。