1、首先为每个路由器的每个接口配置ip
r1:
[r1]interface Serial 4/0/0
[r1-Serial4/0/0]ip address 12.1.1.1 24
[r1-Serial4/0/0]int gi 0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.1.1 24
r2:
[r2-Serial4/0/0]ip add 12.1.1.2 24
[r2-Serial4/0/0]int s 4/0/1
[r2-Serial4/0/1]ipadd 12.1.2.1 24
[r2-Serial4/0/1]int s 3/0/0
[r2-Serial3/0/0]ip add 12.1.3.1 24
[r2]int LoopBack 0
[r2-LoopBack0]ip address 2.2.2.2 24
r3:
[r3]interface Serial 4/0/0
[r3-Serial4/0/0]ip add 12.1.2.2 24
[r3-Serial4/0/0]int gi 0/0/1
[r3-GigabitEthernet0/0/1]ip add 192.168.2.1 24
r4:
[r4]interface Serial 4/0/0
[r4-Serial4/0/0]ip add 12.1.3.2 24
[r4-Serial4/0/0]int gi 0/0/1
[r4-GigabitEthernet0/0/1]ip add 192.168.3.1 24
2、实现第二个目标: r1-r2之间为hdlc封装
r1:
[r1-Serial4/0/0]link-protocol hdlc 修改接口封装类型为hdlc
Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]
:y
r2:
[r2]interface Serial 4/0/0
[r2-Serial4/0/0]link-protocol hdlc 修改接口封装类型为hdlc
’Warning: The encapsulation protocol of the link will be changed. Continue? [Y/N]
:y
测试:在r1连接r2的接口抓包
3、实验第三个要求: r2-r3之间为ppp封装,认证,r2为主认证方
PPP封装:
r2:
[r2]interface Serial 4/0/1
[r2-Serial4/0/1]link-protocol PPP 修改接口封装类型为PPP
r3:
[r3]interface Serial 4/0/0
[r3-Serial4/0/0]link-protocol PPP 修改封装接口类型为PPP
认证:
r2:
[r2]aaa
[r2-aaa]local-user qq privilege level 15 password cipher 123456 创建用户名 密码
Info: Add a new user.
[r2-aaa]local-user qq service-type ppp 设置类型
[r2-aaa]int s4/0/1
[r2-Serial4/0/1]ppp authentication-mode pap 在接口上声明需要pap认证
测试:r2到r3的接口无法ping通
r3(被认证方):
[r3-Serial4/0/0]ppp pap local-user qq password cipher 123456
4、实现第四个要求: r2-r4之间为ppp封装,chap认证,r2为主认证方
r2:
[r2]aaa
[r2-aaa]local-user pp privilege level 15 password cipher 123456
Info: Add a new user.
[r2-aaa]local-user pp service-type ppp
[r2-aaa]int s 3/0/0
[r2-Serial3/0/0]ppp authentication-mode chap
r4:
[r4]interface Serial 4/0/0
[r4-Serial4/0/0]ppp chap user pp
[r4-Serial4/0/0]ppp chap password cipher 123456
5、实现第五个要求:r1,r2,r3构建MGRE环境,仅r1ip地址固定
这里首先让公网内的所有接口互相可达使用缺省路由
[r1]ip route-static 0.0.0.0 0 12.1.1.2
[r3]ip route-static 0.0.0.0 0 12.1.2.1
[r4]ip route-static 0.0.0.0 0 12.1.3.1
然后搭建MGRE环境:
r1(中心站点):
[r1]interface Tunnel 0/0/0 创建隧道接口
[r1-Tunnel0/0/0]ip address 192.168.4.1 24 隧道接口ip
[r1-Tunnel0/0/0]tunnel-protocol gre p2mp 定义该隧道为多点GRE隧道
[r1-Tunnel0/0/0]source 12.1.1.1 该隧道加封装报头源ip地址
通过nhrp协议来获取加封装的目标ip地址
[r1-Tunnel0/0/0]nhrp entry multicast dynamic本地为NHRP服务器
[r1-Tunnel0/0/0]nhrp network-id 100 NHRP的工作编号 ,该网段所有设备必须在同一id
分支站点:
r3:
[r3]interface Tunnel 0/0/0
[r3-Tunnel0/0/0]ip address 192.168.4.2 24
[r3-Tunnel0/0/0]tunnel-protocol gre p2mp
加封装的源ip地址为本地的隧道实际通过接口的ip地址,填写接口编号,而不是接口ip,原因在于该接口ip会变
[r3-Tunnel0/0/0]source GigabitEthernet 0/0/0
加封装的目标ip地址需要到NHRP中心站点获取
[r3-Tunnel0/0/0]nhrp entry 192.168.4.1 12.1.1.1 register
[r3-Tunnel0/0/0]nhrp network-id 100
r4:
[r4]interface Tunnel 0/0/0
[r4-Tunnel0/0/0]ip address 192.168.4.3 24
[r4-Tunnel0/0/0]tunnel-protocol gre p2mp
[r4-Tunnel0/0/0]source GigabitEthernet 0/0/0
[r4-Tunnel0/0/0]nhrp entry 192.168.4.1 12.1.1.1 register
[r4-Tunnel0/0/0]nhrp network-id 100
6、最后实现最后一个目标利用rip动态路由的方式实现全网可达
r1:
[r1]rip 1
[r1-rip-1]version 2
[r1-rip-1]network 192.168.1.0
[r1-rip-1]network 192.168.4.0
r3:
[r3-Tunnel0/0/0]rip 1
[r3-rip-1]version 2
[r3-rip-1]network 192.168.2.0
[r3-rip-1]network 192.168.4.0
r4:
[r4]rip 1
[r4-rip-1]v 2
[r4-rip-1]network 192.168.3.0
[r4-rip-1]network 192.168.4.0
这里因为rip的水平分割机制导致r3无法与与r4分享网段所以需要关闭rip的水平分割机制
[r1]interface Tunnel 0/0/0
[r1-Tunnel0/0/0]undo rip split-horizon
这里注意还有最后一个问题就是每个pc需要可以访问到r2的环回所以需要通过acl和nat的方式实现内网和外网的连通
r1:
[r1]acl 2000
[r1-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[r1]interface Serial 4/0/0
[r1-Serial4/0/0]nat outbound 2000
r2:
[r3]acl 2000
[r3-acl-basic-2000]rule permit source 192.168.2.0 0.0.0.255
[r3]interface Serial 4/0/0
[r3-Serial4/0/0]nat outbound 2000
r4:
[r4]acl 2000
[r4-acl-basic-2000]rule permit source 192.168.3.0 0.0.0.255
[r4]interface Serial 4/0/0
[r4-Serial4/0/0]nat outbound 2000
测试: