拓扑图
如图所示,Router1与Router2之间使用PPP的pap认证方式,Router2与Router3之间使用chap认证方式
Router1为DHCP服务器,路由协议使用RIP
首先为各个路由器的端口设置地址
Router1的配置
Router>en
Router#conf t
Router(config)#hostname Router1
Router1(config)#enable secret 123 //为路由器的特权模式设置密码
Router1(config)#int s0/0/0
Router1(config-if)#ip addr 10.1.1.1 255.255.255.0
Router1(config-if)#clock rate 64000
Router1(config-if)#no shu
Router1(config-if)#exit
Router1(config)#int f0/0
Router1(config-if)#ip addr 192.168.11.1 255.255.255.0
Router1(config-if)#no shu
Router1(config-if)#exit
Router1(config)#
Router2的配置
Router>en
Router#conf t
Router(config)#hostname Router2
Router2(config)#enable secret 123
Router2(config)#int s0/0/0
Router2(config-if)#ip addr 10.1.1.2 255.255.255.0
Router2(config-if)#no shu
Router2(config-if)#exit
Router2(config)#int s0/0/1
Router2(config-if)#ip addr 20.1.1.1 255.255.255.0
Router2(config-if)#clock rate 64000
Router2(config-if)#no shu
Router2(config-if)#exit
Router2(config)#int f0/0
Router2(config-if)#ip addr 192.168.22.1 255.255.255.0
Router2(config-if)#no shu
Router2(config-if)#exit
Router2(config)#
Router3的配置
Router>en
Router#conf t
Router(config)#hostname Router3
Router2(config)#enable secret 123
Router3(config)#int f0/0
Router3(config-if)#ip addr 192.168.33.1 255.255.255.0
Router3(config-if)#no shu
Router3(config-if)#exit
Router3(config)#int s0/0/0
Router3(config-if)#ip addr 20.1.1.2 255.255.255.0
Router3(config-if)#no shu
Router3(config-if)#exit
Router1与Router2之间的pap认证封装
Router1的配置
Router1(config)#username Router2 password 123 //记录对端路由器的名字和密码
Router1(config)#int s0/0/0
Router1(config-if)#encapsulation ppp //使用点对点协议
Router1(config-if)#ppp authentication pap //使用pap认证方式
Router1(config-if)#ppp pap sent-username Router1 password 123 //传输用户名和密码
Router2的配置
Router2(config)#username Router1 password 123
Router2(config)#int s0/0/0
Router2(config-if)#encapsulation ppp
Router2(config-if)#ppp authentication pap
Router2(config-if)#ppp pap sent-username Router2 passwo rd 123
查看Router1的端口状况
Router1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.11.1 YES manual up up
FastEthernet0/1 unassigned YES NVRAM administratively down down
Serial0/0/0 10.1.1.1 YES manual up up
Vlan1 unassigned YES NVRAM administratively down down
Router1#
查看Router2的端口状况
Router2#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.22.1 YES manual up up
FastEthernet0/1 unassigned YES NVRAM administratively down down
Serial0/0/0 10.1.1.2 YES manual up up
Serial0/0/1 20.1.1.1 YES manual up up
Vlan1 unassigned YES NVRAM administratively down down
Router2#
查看Router1 的端口s0/0/0
Router1#show int s0/0/0
Serial0/0/0 is up, line protocol is up (connected)
Hardware is HD64570
Internet address is 10.1.1.1/24
MTU 1500 bytes, BW 128 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation PPP, loopback not set, keepalive set (10 sec) //封装协议已为PPP
LCP Open
Open: IPCP, CDPCP
用Router1 ping Router2
Sending 5, 100-byte ICMP Echos to 10.1.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 7/9/18 ms
Router2(config)#int s0/0/1
Router2(config-if)#encapsulation ppp
Router2(config-if)#ppp authentication chap
Router3(config)#int s0/0/0
Router3(config-if)#encapsulation ppp
Router3(config-if)#ppp authentication chap
Serial0/0/1 is up, line protocol is up (connected)
Hardware is HD64570
Internet address is 20.1.1.1/24
MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation PPP, loopback not set, keepalive set (10 sec)
LCP Open
Open: IPCP, CDPCP
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.33.1 YES manual up up
FastEthernet0/1 unassigned YES unset administratively down down
Serial0/0/0 20.1.1.2 YES manual up up
Serial0/0/1 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
Router3#
Sending 5, 100-byte ICMP Echos to 20.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/7/10 ms
Router1(config-router)#ver 2
Router1(config-router)#network 192.168.11.0
Router1(config-router)#network 10.1.1.0
Router1(config-router)#no auto-summary
Router2(config-router)#ver 2
Router2(config-router)#network 192.168.22.0
Router2(config-router)#network 10.1.1.0
Router2(config-router)#network 20.1.1.0
Router2(config-router)#no auto-summary
Router3(config-router)#ver 2
Router3(config-router)#network 192.168.22.0
Router3(config-router)#network 20.1.1.0
Router3(config-router)#no auto-summary
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
C 10.1.1.0/24 is directly connected, Serial0/0/0
C 10.1.1.2/32 is directly connected, Serial0/0/0
20.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
R 20.0.0.0/8 is possibly down, routing via 10.1.1.2, Serial0/0/0
R 20.1.1.0/24 [120/1] via 10.1.1.2, 00:00:26, Serial0/0/0
C 192.168.11.0/24 is directly connected, FastEthernet0/0
R 192.168.22.0/24 [120/1] via 10.1.1.2, 00:00:26, Serial0/0/0
R 192.168.33.0/24 [120/2] via 10.1.1.2, 00:00:26, Serial0/0/0
Router1#
Router1(dhcp-config)#network 192.168.11.0 255.255.255.0 //地址所划分网络的网络号
Router1(dhcp-config)#default-router 192.168.11.1 //DHCP服务器分配的默认网关
Router1(dhcp-config)#exit
Router1(config)#ip dhcp excluded-address 192.168.11.1 192.168.11.5 //保留地址段 保留192.168.11.1~.5之间的地址
Router1(config)#ip dhcp pool pool-2
Router1(dhcp-config)#network 192.168.22.0 255.255.255.0
Router1(dhcp-config)#default-router 192.168.22.1
Router1(dhcp-config)#exit
Router1(config)#ip dhcp excluded-address 192.168.22.1 192.168.22.5
Router1(config)#ip dhcp pool pool-3
Router1(dhcp-config)#network 192.168.33.0 255.255.255.0
Router1(dhcp-config)#default-router 192.168.33.1
Router1(dhcp-config)#exit
Router1(config)#ip dhcp excluded-address 192.168.33.1 192.168.33.5
Router2(config-if)#ip helper-address 10.1.1.1 //距离最近的DHCP服务器的端口的IP地址
Router3(config-if)#ip helper-address 10.1.1.1
pc 2
pc 3
最后使用ping命令来检查网络
pc1 ping pc2
pc1 ping pc3
实验结束