第一步, 配置IP地址以及写好静态路由:
[r1]ip route-static 0.0.0.0 0 15.0.0.2
[r2]ip route-static 0.0.0.0 0 25.0.0.2
[r3]ip route-static 0.0.0.0 0 35.0.0.2
[r4]ip route-static 0.0.0.0 0 45.0.0.2
r5:
第二步,R1和R5间使用ppp的PAP认证,R5为主认证方:
R5:
R5:
[r5]aaa
[r5-aaa]local-user xj password cipher 123456
Info: Add a new user.
[r5-aaa]local-user xj service-type ppp
[r5-aaa]q
[r5]int s3/0/0
[r5-Serial3/0/0]ppp authentication-mode pap
R1:
[r1]int s4/0/0
[r1-Serial4/0/0]ppp pap local-user xj password cipher 123456
第三步,R2与R5之间使用PPP的chap认证,R5为主认证方:
R2:
[r2]int s4/0/0
[r2-Serial4/0/0]ppp chap user xj
[r2-Serial4/0/0]ppp chap password simple 123456
R5:
[r5]int s3/0/1
[r5-Serial3/0/1]ppp authentication-mode chap
第四步,R3与R5之间使用HDLC封装:
[r3]int s4/0/0
[r3-Serial4/0/0]link-protocol hdlc
[r5]int s4/0/0
[r5-Serial4/0/0]link-protocol hdlc
第五步,.R1/R2/R3构建一个MGRE环境,R1为中心站点;R1、R4间为点到点的GRE。
1.先进行环境配置
R1主干线路:
[r1]int t 0/0/0 ——————创建虚拟隧道接口
[r1-Tunnel0/0/0]ip address 192.168.5.1 24 ————IP地址是虚拟的
[r1-Tunnel0/0/0]tunnel-protocol gre p2mp ——————定义封装方式
[r1-Tunnel0/0/0]source 15.0.0.1 ——————定义封装内容,因为R1为中心站点,其出接口为15.0.0.1,所以我将院IP地址选择为15.0.0.1
[r1-Tunnel0/0/0]nhrp network-id 100 ——声明id,具有全局意义,类似于一个大范围,其他分支可以通过查找100这个门牌号,找到主干线路。
[r1-Tunnel0/0/0]
R2分支:
[r2]int t 0/0/0 ——————创建虚拟隧道接口
[r2-Tunnel0/0/0]ip address 192.168.5.2 24
[r2-Tunnel0/0/0]tunnel-protocol gre p2mp ——————定义封装方式
[r2-Tunnel0/0/0]source Serial 4/0/0 ——————定义封装内容。因为其IP地址可能发生变化,但是接口是不会变的,如果以接口为源目标,那么其可靠性就得到了很大的保障。
[r2-Tunnel0/0/0]nhrp network-id 100 ——————通过查找100这个区域号,然后加入到里面去
[r2-Tunnel0/0/0]nhrp entry 192.168.5.1 15.0.0.1 register ——————将分支信息上报到主干线路R1里面
R3分支:(原理同R2)
[r3]int t 0/0/0
[r3-Tunnel0/0/0]ip address 192.168.5.3 24
[r3-Tunnel0/0/0]tunnel-protocol gre p2mp
[r3-Tunnel0/0/0]source Serial 4/0/0
[r3-Tunnel0/0/0]nhrp network-id 100
[r3-Tunnel0/0/0]nhrp entry 192.168.5.1 15.0.0.1 register
2、GRE环境
R1到R4的路线分析:
真实的路线走法:源:15.0.0.1/24 | 目标:45.0.0.1/24
希望的路线走法:源:192.168.5.1/24 | 目标: 192.168.5.4
加了GRE后的走法:源:15.0.0.1/24 | 目标:45.0.0.1/24 |GRE| 源:192.168.5.1/24 | 目标: 192.168.5.4 |数据
R1:
[r1]int t 0/0/0
[r1-Tunnel0/0/0]ip address 192.168.6.1 24
[r1-Tunnel0/0/0]tunnel-protocol gre
[r1-Tunnel0/0/0]source 15.0.0.1
[r1-Tunnel0/0/0]description 45.0.0.1
[r1-Tunnel0/0/0]
R4:
[r4]int t 0/0/0
[r4-Tunnel0/0/0]ip address 192.168.5.4 24
[r4-Tunnel0/0/0]tunnel-protocol gre
[r4-Tunnel0/0/0]source 45.0.0.1
[r4-Tunnel0/0/0]description 15.0.0.1
[r4-Tunnel0/0/0]
3、配置公网环境
[r1]ip route-static 0.0.0.0 0 15.0.0.2
[r2]ip route-static 0.0.0.0 0 25.0.0.2
[r3]ip route-static 0.0.0.0 0 35.0.0.2
[r4]ip route-static 0.0.0.0 0 45.0.0.2
[r1]ip route-static 192.168.2.0 24 192.168.5.2
[r1]ip route-static 192.168.3.0 24 192.168.5.3
[r2]ip route-static 192.168.1.0 24 192.168.5.1
[r2]ip route-static 192.168.3.0 24 192.168.5.3
[r3]ip route-static 0.0.0.0 0 35.0.0.2
[r3]ip route-static 192.168.2.0 24 192.168.5.2
[r3]ip route-static 192.168.1.0 24 192.168.5.1
第六步配置RIP
[r1]rip
[r1-rip-1]version 2
[r1-rip-1]network 192.168.6.0
[r1-rip-1]network 192.168.5.0
[r1-rip-1]network 192.168.1.0
[r1-rip-1]network 1.0.0.0
[r1-rip-1]q
[r1]int t 0/0/0
[r1-Tunnel0/0/0]undo rip split-horizon
[r1-Tunnel0/0/0]
[r2]rip
[r2-rip-1]version 2
[r2-rip-1]network 2.0.0.0
[r2-rip-1]network 192.168.5.0
[r2-rip-1]network 192.168.2.0
[r2-rip-1]
[r3]rip
[r3-rip-1]version 2
[r3-rip-1]network 3.0.0.0
[r3-rip-1]network 192.168.5.0
[r3-rip-1]network 192.168.3.0
[r3-rip-1]
[r4]rip
[r4-rip-1]version 2
[r4-rip-1]network 4.0.0.0
[r4-rip-1]network 192.168.6.0
[r4-rip-1]network 192.168.5.0
[r4-rip-1]network 192.168.4.0
[r4-rip-1]
将所有私有IP设置为源IP,可以访问R5环回(使用NAT映射)
————————R1
[r1]acl 2000
[r1-acl-basic-2000]rule permit source 1.0.0.0 0.255.255.255
[r1-acl-basic-2000]int s 4/0/0
[r1-Serial4/0/0]nat outbound 2000
[r1-Serial4/0/0]
————————R2
[r2]acl 2000
[r2-acl-basic-2000]rule permit source 2.0.0.0 0.255.255.255
[r2-acl-basic-2000]int s 4/0/0
[r2-Serial4/0/0]nat outbound 2000
[r2-Serial4/0/0]
————————R3
[r3]acl 2000
[r3-acl-basic-2000]rule permit source 3.0.0.0 0.255.255.255
[r3-acl-basic-2000]int s 4/0/0
[r3-Serial4/0/0]nat outbound 2000
[r3-Serial4/0/0]
————————R4
[r4]acl 2000
[r4-acl-basic-2000]rule permit source 4.0.0.0 0.255.255.255
[r4-acl-basic-2000]int g 0/0/0
[r4-GigabitEthernet0/0/0]nat outbound 2000
[r4-GigabitEthernet0/0/0]