MGRE环境下的OSPF实验
OSPF(开放式最短路径优先协议)+MGRE(多点GRE)
实验步骤:
首先配置所有接口地址,写所有路由器到R6的缺省
1.配置缺省
[r1]ip route-static 0.0.0.0 0 16.1.1.2
[r1]ip route-static 0.0.0.0 0 61.1.1.2
[r2]ip route-static 0.0.0.0 0 26.1.1.2
[r3]ip route-static 0.0.0.0 0 36.1.1.2
[r4]ip route-static 0.0.0.0 0 46.1.1.2
[r5]ip route-static 0.0.0.0 0 56.1.1.2
给R6上写一个环回6.6.6.6 24
ACL不能在路由器上做,思科上说ACL不能过滤自身流量,需要给每个路由器连接一台电脑,使用电脑上DHCP自动获取IP地址,在PC上ping6.6.6.6来检测私有网段的设置
2.DHCP+NAT
dhcp enbale
ip pool 1
[r1-ip-pool-1]network 192.168.1.0 mask 24
[r1-ip-pool-1]dns-list 114.114.114.114 8.8.8.8
[r-ip-pool-1]gateway-list 192.168.1.254
[r1-GigabitEthernet0/0/2]dhcp select global
[r1-GigabitEthernet0/0/2]ip address 192.168.1.254 24
[r1]ACL 2000
[r1-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[r1-acl-basic-2000]int g0/0/0
[r1-GigabitEthernet0/0/0]nat outbound 2000
dhcp enbale
ip pool 2
[r2-ip-pool-2]network 192.168.2.0 mask 24
[r2-ip-pool-2]dns-list 114.114.114.114 8.8.8.8
[r2-ip-pool-2]gateway-list 192.168.2.254
[r2-GigabitEthernet0/0/2]dhcp select global
[r2-GigabitEthernet0/0/2]ip address 192.168.2.254 24
[r2]acl 2000
[r2-acl-basic-2000]rule permit source 192.168.2.0 0.0.0.255
[r2-acl-basic-2000]int g0/0/0
[r2-GigabitEthernet0/0/0]nat outbound 2000
[r3]dhcp enable
[r3]ip pool 3
[r3-ip-pool-3]network 192.168.3.0 mask 24
[r3-ip-pool-3]gateway-list 192.168.3.254
[r3-ip-pool-3]dns-list 114.114.114.114 8.8.8.8
[r3-ip-pool-3]int g0/0/2
[r3-GigabitEthernet0/0/2]dhcp select global
[r3-GigabitEthernet0/0/2]ip address 192.168.3.254 24
[r3]acl 2000
[r3-acl-basic-2000]rule permit source 192.168.3.0 0.0.0.255
[r3-acl-basic-2000]int g 0/0/0
[r3-GigabitEthernet0/0/0]nat outbound 2000
[r4]dhcp enable
[r4]ip pool 4
[r4-ip-pool-4]network 192.168.4.0 mask 24
[r4-ip-pool-4]gateway-list 192.168.4.254
[r4-ip-pool-4]dns-list 114.114.114.114 8.8.8.8
[r4-ip-pool-4]int g0/0/2
[r4-GigabitEthernet0/0/2]ip address 192.168.4.254 24
[r4-GigabitEthernet0/0/2]dhcp select global
[r4]acl 2000
[r4-acl-basic-2000]rule permit source 192.168.4.0 0.0.0.255
[r4-acl-basic-2000]int g 0/0/0
[r4-GigabitEthernet0/0/0]nat outbound 2000
[r4-GigabitEthernet0/0/0]int g0/0/2
[r5]dhcp enable
[r5]ip pool 5
[r5-ip-pool-5]network 192.168.5.0 mask 24
[r5-ip-pool-5]gateway-list 192.168.5.254
[r5-ip-pool-5]dns-list 114.114.114.114 8.8.8.8
[r5-ip-pool-5]int g0/0/2
[r5-GigabitEthernet0/0/2]dhcp select global
[r5-GigabitEthernet0/0/2]ip address 192.168.5.254 24
[r5]acl 2000
[r5-acl-basic-2000]rule permit source 192.168.5.0 0.0.0.255
[r5-acl-basic-2000]int g0/0/0
[r5-GigabitEthernet0/0/0]nat outbound 2000
每个私网都可以访问R6的环回地址
3.R1R4R5为全连MGRE
将R1R4都作为中心站点,给R5写到R1R4的注册,然后R1找R4注册。
[r1]int Tunnel0/0/0
[r1-Tunnel0/0/0]ip address 10.1.1.1 24
[r1-Tunnel0/0/0]tunnel-protocol gre p2mp
[r1-Tunnel0/0/0]source 16.1.1.1
[r1-Tunnel0/0/0]nhrp entry multicast dynamic
[r1-Tunnel0/0/0]nhrp network-id 100
[r1-Tunnel0/0/0]nhrp entry 10.1.1.2 46.1.1.1 register
[r4]int tunnel 0/0/0
[r4-Tunnel0/0/0]ip address 10.1.1.2 24
[r4-Tunnel0/0/0]tunnel-protocol gre p2mp
[r4-Tunnel0/0/0]source 46.1.1.1
[r4-Tunnel0/0/0]nhrp network-id 100
[r1-Tunnel0/0/0]nhrp entry multicast dynamic
[r5]int Tunnel 0/0/0
[r5-Tunnel0/0/0]ip address 10.1.1.3 24
[r5-Tunnel0/0/0]tunnel-protocol gre p2mp
[r5-Tunnel0/0/0]source 56.1.1.1
[r5-Tunnel0/0/0]nhrp network-id 100
[r5-Tunnel0/0/0]nhrp entry 10.1.1.1 16.1.1.1 register
[r5-Tunnel0/0/0]nhrp entry 10.1.1.2 46.1.1.1 register
R4和R1,当R1去R4注册后,R4中可以找到10.1.1.1 地址
可以看到,此时R4为中心站点,可以找到R1和R5
4.测试MGRE
5.OSPF的启动
[r1]ospf 10 router-id 1.1.1.1
[r1-ospf-10]area 0
[r1-ospf-10-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[r1-ospf-10-area-0.0.0.0]network 10.1.1.0 0.0.0.255
Tunnel—点到点
[r1-Tunnel0/0/0]ospf network-type broadcast
[r4]ospf 10 router-id 4.4.4.4
[r4-ospf-10]area 0
[r4-ospf-10-area-0.0.0.0]network 192.168.4.0 0.0.0.255
[r4-ospf-10-area-0.0.0.0]network 10.1.1.0 0.0.0.255
Tunnel—点到点
[r4-Tunnel0/0/0]ospf network-type broadcast
[r5]ospf 10 router-id 5.5.5.5
[r5-ospf-10]area 0
[r5-ospf-10-area-0.0.0.0]network 192.168.5.0 0.0.0.255
[r5-ospf-10-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[r5-Tunnel0/0/0]ospf network-type broadcast
6.R1 R2 R3 为星型的拓扑结构,R1为中心站点,MGRE
[r1]int Tunnel 0/0/1
[r1-Tunnel0/0/1]ip address 20.1.1.1 24
[r1-Tunnel0/0/1]tunnel-protocol gre p2mp
[r1-Tunnel0/0/1]nhrp network-id 100
[r1-Tunnel0/0/1]sou
[r1-Tunnel0/0/1]source 61.1.1.1
[r1-Tunnel0/0/1]nhrp entry multicast dynamic
[r2]int Tunnel0/0/1
[r2-Tunnel0/0/1]ip address 20.1.1.2 24
[r2-Tunnel0/0/1]tunnel-protocol gre p2mp
[r2-Tunnel0/0/1]source 26.1.1.1
[r2-Tunnel0/0/1]nhrp network-id 100
[r2-Tunnel0/0/1]nhrp entry 20.1.1.1 61.1.1.1 register
[r3]int Tunnel0/0/1
[r3-Tunnel0/0/1]ip address 20.1.1.3 24
[r3-Tunnel0/0/1]tunnel-protocol gre p2mp
[r3-Tunnel0/0/1]source 36.1.1.1
[r3-Tunnel0/0/1]nhrp network-id 100
[r3-Tunnel0/0/1]nhrp entry 20.1.1.1 61.1.1.1 register
7.需要求改所有DR优先权
[r1-ospf-10-area-0.0.0.0]undo network 20.1.1.1 0.0.0.255
[r1-Tunnel0/0/1]ospf network-type broadcast
[r1-Tunnel0/0/0]ospf dr-priority 255
[r2]ospf 10 router-id 2.2.2.2
[r2-ospf-10]area 0
[r2-ospf-10-area-0.0.0.0]network 20.1.1.2 0.0.0.255
[r2-Tunnel0/0/1]ospf network-type broadcast
[r2-Tunnel0/0/1]ospf dr-priority 0
r3]ospf 10 router-id 3.3.3.3
[r3-ospf-10]area 0
[r3-ospf-10-area-0.0.0.0]network 192.168.3.0 0.0.0.255
[r3-ospf-10-area-0.0.0.0]network 20.1.1.0 0.0.0.255
[r3-Tunnel0/0/1]ospf network-type broadcast
[r3-Tunnel0/0/1]ospf dr-priority 0
测试结果:
PC1pingPC2 PC3 PC4 PC5 检测OSPF是否设置成功