1.R1、R2、R3、R4是一个公网环境,先使它们互通
【R1】
int s0/0
ip add 200.1.1.1 255.255.255.0
no shutdown
【R2】
int s0/0
ip add 200.1.1.2 255.255.255.0
no shutdown
int s0/1
ip add 200.1.3.2 255.255.255.0
no shutdown
int s0/2
ip add 200.1.4.2 255.255.255.0
no shutdown
【R3】
int s0/0
ip add 200.1.3.3 255.255.255.0
no shutdown
【R4】
int s0/0
ip add 200.1.4.4 255.255.255.0
no shutdown
测试R2和R1、R3、R4是否ping通
写一条指向R2的默认路由
【R1】
ip route 0.0.0.0 0.0.0.0 200.1.1.2
【R3】
ip route 0.0.0.0 0.0.0.0 200.1.3.2
【R4】
ip route 0.0.0.0 0.0.0.0 200.1.4.2
测试R1、R3、R4三者是否互通
2.配置DMVPN
【R1】
int tunnel 0
ip add 10.1.1.1 255.255.255.0
tunnel source s0/0
tunnel mode gre multipoint
tunnel key 100
ip nhrp network-id 100
ip nhrp authentication cisco
【R3/R4】R3、R4只有tunnel 0的地址不同
int tunnel 0
ip add 10.1.1.3(10.1.1.4) 255.255.255.0
tunnel source s0/0
tunnel mode gre multipoint 默认是gre的点到点模式,须更改为多点gre模式
tunnel key 100
ip nhrp nhs 10.1.1.1 找nhs即R1
ip nhrp map 10.1.1.1 200.1.1.1 把tunnel地址映射到公网地址
ip nhrp network-id 100
ip nhrp authentication cisco
配置完成后需要触发:
ping 10.1.1.4
查看映射:
show ip nhrp / show dmvpn 默认的网络类型为NBMA
【R3】
traceroute 10.1.1.4 numeric 结果为一跳到达
最终目的是PC互通,所以在路由器上起环回,并写一条静态路由
【R3】
int lo0
ip add 3.3.3.3 255.255.255.255
ip route 4.4.4.4 255.255.255.255 10.1.1.4
【R4】
int lo0
ip add 4.4.4.4 255.255.255.255
ip route 3.3.3.3 255.255.255.255 10.1.1.3
分支之间的内网地址直接通信,达成
以上是DMVPN的第一阶段
第二阶段启用动态路由协议,宣告tunnel地址及回环地址,删掉之前的静态路由:
eigrp的情况,R1上可能看不到eigrp的路由,把R3和R4的tunnel口重新打开一次
【R3】
no ip route 4.4.4.4 255.255.255.255 10.1.1.4
router eigrp 90
network 10.1.1.3
network 3.3.3.3
int t0
ip nhrp map multicast 200.1.1.1
【R4】
no ip route 3.3.3.3 255.255.255.255 10.1.1.3
router eigrp 90
network 10.1.1.4
network 4.4.4.4
int t0
ip nhrp map multicast 200.1.1.1
【R1】
int t0
ip nhrp map multicast dynamic
no ip split-horizon eigrp 90 spoke路由在tunnel口进出,R3和R4不能建立eigrp邻居,必须关闭水平分割
no ip next-self-hop eigrp 90 R3去R4下一跳是R1,必须修改下一跳,本质上是因为eigrp是距离矢量型路由协议,路由在传递过程中进行矢量叠加(修改)
如果不关闭eigrp的水平分割,可以通过全互联实现R3和R4的建邻,这只限于分支少的情况:
【R1】
ip split-horizon eigrp 90
ip next-self-hop eigrp 90
【R3】
int t0
ip nhrp map multicast 200.1.4.4 映射到R4的公网地址
【R4】
int t0
ip nhrp map multicast 200.1.3.3
OSPF的情况:tunnel口默认的ospf的网络类型是点到点,配置完ospf会报错,no logging console 可以避免大量报错日志,如果把网络类型改为点到多点,traceroute时为两跳,改为广播则为一跳,改为广播时R3和R4同时要改优先级(必须把spoke的优先级改为0,而不是把hub的优先级改大---OSPF是链路状态型协议,下一跳取决于拓扑图的结构,而在MA环境下,spoke和spoke是直连的。所以spoke的路由表中下一跳直接指向目标spoke的tunnel地址),保证hub为DR。OSPF要达成第二阶段,必须把网络类型改为BMA/NBMA
【R1】
router ospf 1
network 4.4.4.4 0.0.0.0 a 0
network 10.1.1.0 0.0.0.255 a 0
int t0
ip ospf network point-to-multipoint
【R3】
no ip nhrp map multicast 200.1.4.4
router ospf 1
network 4.4.4.4 0.0.0.0 a 0
network 10.1.1.0 0.0.0.255 a 0
int t0
ip ospf network point-to-multipoint
【R4】
no ip nhrp map multicast 200.1.3.3
router ospf 1
network 4.4.4.4 0.0.0.0 a 0
network 10.1.1.0 0.0.0.255 a 0
int t0
ip ospf network point-to-multipoint
【R1】
int t0
ip ospf network broadcast
【R3/R4】
int t0
ip ospf network broadcast
ip ospf priority 0
以上为第二阶段