实验目的是通过GRE技术在两个site 点建立隧道(tunnel)并且在tunnel上运行动态路由器(OSPF)以彼此学习对方的内网。实现穿透internet 两个分公司互访,下图分别模拟公司一(Site1),internet,公司二(Site2)。分别以loopback 0 模拟公司内网网段。
实验拓扑介绍:
公司一(site 1)路由器的E0/0接口连接 internet 路由器的E0/0 接口,internet路由器的E0/1接口连接公司二(site2)路由器E0/0接口。Site 1 与site 2 内网互访即:1.1.1.0/24与2.2.2.0/24互访。1.1.1.1/24 模拟site 1 PC 的ip,2.2.2.2/24模拟site 2 PC的ip。
基本配置:
Site 1 基本配置:
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface Ethernet0/0
description to internet_router
ip address 202.100.1.1 255.255.255.0
!
!
ip route 0.0.0.0 0.0.0.0 Ethernet0/0 202.100.1.10
site 2 基本配置
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface Ethernet0/0
description to internet_router
ip address 202.100.2.1 255.255.255.0
ip route 0.0.0.0 0.0.0.0 202.100.2.10
internet 基本配置
hostname Internet
!
interface Ethernet0/0
description to site1_router
ip address 202.100.1.10 255.255.255.0
!
interface Ethernet0/1
description to site2_router
ip address 202.100.2.10 255.255.255.0
GRE 基本配置与OSPF配置
基本配置已经配置完成,现在配置site 1 到site 2 的隧道(tunnel)把两个点虚拟的互连起来。设定tunnel的网段为123.1.1.0/24 ,site 1 为123.1.1.1/24,site 2为123.1.1.2.24。在这个GRE tunnel上配置OSPF ,把内部网络宣布在ospf上。
site 1 GRE 配置与OSPF配置
Site1#configure terminal
Site1(config)#int tunnel 0
Site1(config-if)#ip add 123.1.1.1 255.255.255.0
Site1(config-if)#tunnel source 202.100.1.1
Site1(config-if)#tunnel destination 202.100.2.1
Site1(config-if)#exit
Site1(config)#router ospf 1
Site1(config-router)#log-adjacency-changes
Site1(config-router)#network 1.1.1.0 0.0.0.255 area 0
Site1(config-router)#network 123.1.1.0 0.0.0.255 area 0
Site 2 GRE配置与ospf 配置
site2#configure terminal
site2(config)#int tunnel 0
site2(config-if)#ip add 123.1.1.2 255.255.255.0
site2(config-if)#tunnel source 202.100.2.1
site2(config-if)#tunnel destination 202.100.1.1
site2(config-if)#exi
site2(config)#router ospf 1
site2(config-router)#log-adjacency-changes
site2(config-router)#network 2.2.2.0 0.0.0.255 a
site2(config-router)#network 2.2.2.0 0.0.0.255 area 0
site2(config-router)#network 123.1.1.0 0.0.0.255 area 0
检查状态与测试
1.在site 1 路由器上查看能否通过ospf 学习到2.2.2.2/24 路由,并且下一条是123.1.1.2
Site1#sh ip route ospf
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
i - IS-IS, su - IS-IS summary, 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, H - NHRP, l - LISP
+ - replicated route, % - next hop override
Gateway of last resort is 202.100.1.10 to network 0.0.0.0
2.0.0.0/32 is subnetted, 1 subnets
O2.2.2.2 [110/1001] via 123.1.1.2, 00:02:25, Tunnel0
2.在site 1 路由器用loopback 0 地址1.1.1.1ping site 2 路由器上的loopback 0 地址2.2.2.2
Site1#ping 2.2.2.2 source 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms