NHRP 配置全网状互联GRE隧道

由于GRE是建立点对点的隧道,如果要多个端点的网状互联,则必须采用这种Hub-and-spoke的拓扑形式

但是可以通过使用NHRP(Next-Hop Resolution Protocol)来自动建立全网状拓扑

 

试验拓扑

基本配置:

Hub Router

hostname Hub
!
interface Tunnel0
 ip address 10.0.0.1 255.255.255.0
 ip nhrp authentication test    //启动认证密钥,用来不被路由欺骗,常用于WAN边界的安全考虑;
 ip nhrp map multicast dynamic    //详情看下面注意
 ip nhrp network-id 100000    //指定网络域,同一个TUNNEL必须处在相同的区域,且是一个子网中
 ip nhrp holdtime 600    //检测对端失效计时器,默认的时间是2小时,这个也是必须的
 ip nhrp cache non-authoritative    //这是默认产生的
 no ip split-horizon eigrp 1    //由于在物理上spoke到spoke的数据包还是要经过hub,所以这里的eigrp必须关闭水平分割,hub才能向spoke通告从其他spoke学习到的路由
 tunnel source Ethernet0
 tunnel mode gre multipoint    //设置隧道接口的封装模式为mGRE
 tunnel key 500 //为隧道设置密钥,隧道的两端必须相同
!
interface Ethernet0 
  ip address 172.17.0.1 255.255.255.0 

interface Ethernet1 
  ip address 192.168.0.1 255.255.255.0 

router eigrp 1 
  network 10.0.0.0 0.0.0.255 
  network 192.168.0.0 0.0.0.255 
  no auto-summary 
!
 

Spoke1 Router

hostname Spoken1
!
interface Tunnel0
 ip address 10.0.0.2 255.255.255.0
 ip nhrp authentication test
 ip nhrp map 10.0.0.1 172.17.0.1    //ip nhrp map [Logical IP] [NBMA IP]
创建一个逻辑IP地址和NBMA地址的静态绑定,

  • Logical IP为可达的NBMA网络的目的地址,也就是隧道内部的地址,或者说逻辑地址
  • NBMA IP为可达的NBMA网络的物理接口地址,也就是Hub的Tunnel接口的tunnel source地址

 ip nhrp map multicast 172.17.0.1    //ip nhrp map multicast [StaticIP]
分支必须要静态指向Hub的物理接口地址,详情看下面注意
 ip nhrp network-id 100000
 ip nhrp holdtime 300
 ip nhrp nhs 10.0.0.1    //将Hub的隧道地址作为spoke到下一跳路由的服务器,用于处理spoke的NHRP查询
 ip nhrp cache non-authoritative
 tunnel source Ethernet0
 tunnel destination 172.17.0.1
 tunnel key 500
!
interface Ethernet0 
  ip address 172.16.1.1 255.255.255.0

interface Ethernet1 
  ip address 192.168.1.1 255.255.255.0 

router eigrp 1 
  network 10.0.0.0 0.0.0.255 
  network 192.168.1.0 0.0.0.255 
  no auto-summary 

Spoke2 Router

hostname Spoken2
!
interface Tunnel0
 ip address 10.0.0.3 255.255.255.0
 ip nhrp authentication test
 ip nhrp map multicast 172.17.0.1
 ip nhrp map 10.0.0.1 172.17.0.1
 ip nhrp network-id 100000
 ip nhrp holdtime 300
 ip nhrp nhs 10.0.0.1
 ip nhrp cache non-authoritative
 tunnel source Ethernet0
 tunnel destination 172.17.0.1
 tunnel key 500
!
interface Ethernet0 
  ip address 172.16.2.1 255.255.255.0

interface Ethernet1 
  ip address 192.168.2.1 255.255.255.0 

router eigrp 1 
  network 10.0.0.0 0.0.0.255 
  network 192.168.2.0 0.0.0.255 
  no auto-summary 

注意:ip nhrp map multicast dynamic|[StaticIP] 这条命令的目的和帧中继配置中的“frame-relay map… broadcast”一样。指定了将要接收路由器发起的多播和广播流量的目的地。Spokes映射多播地址到Hub的静态的NBMA IP地址(物理接口地址),但是Hub映射多播数据包到“dynamic”地址,这样意味着Hub会复制多播数据包到所有的通过NHRP注册过的Spoke,多播地址映射是用来保证动态路由协议建立邻居和交换更新数据包的,如果不使用动态路由协议,则可以不用配置。

最后进行验证:

从spoke去traceroute到spoke,

第一步:Spoke1的下一跳查询服务器是通过命令静态指定的Hub的172.17.0.1地址,Spoke查询自己的NHRP表,到NHS上去查询10.0.0.3怎么走?


spoke静态配置了hub隧道地址到物理地址的映射
 

第二部:HUB查看自己的NHRP表,向Spoke1返回Spoke2的物理接口地址


在HUB上查看,可以看到已经动态注册了3个spoke隧道地址到物理地址的映射
 

最后tracert成功