
NHRP 配置全网状互联GRE隧道.docx
5页由于 GRE 是建立点对点的隧道,如果要多个端点的网状互联,则必须采用这种Hub-and-spoke 的拓扑形式但是可以通过使用 NHRP(Next-Hop Resolution Protocol)来自动建立全网状拓扑试验拓扑基本配置:Hub Routerhostname Hub!interface Tunnel0ip address 10.0.0.1 255.255.255.0ip 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 Ethernet0tunnel mode gre multipoint //设置隧道接口的封装模式为 mGREtunnel 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 Tunnel0ip address 10.0.0.2 255.255.255.0ip nhrp authentication testip 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 100000ip nhrp holdtime 300ip nhrp nhs 10.0.0.1 //将 Hub 的隧道地址作为 spoke 到下一跳路由的服务器,用于处理 spoke 的 NHRP 查询ip nhrp cache non-authoritativetunnel source Ethernet0tunnel destination 172.17.0.1tunnel 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 Tunnel0ip address 10.0.0.3 255.255.255.0ip nhrp authentication test////ip nhrp map multicast 172.17.0.1ip nhrp map 10.0.0.1 172.17.0.1ip nhrp network-id 100000ip nhrp holdtime 300ip nhrp nhs 10.0.0.1ip nhrp cache non-authoritativetunnel source Ethernet0tunnel destination 172.17.0.1tunnel 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 成功。












