PPP
         PPP协议是点到点的数据链路层协议,也是目前使用最广泛的广域网协议,具有很多好的特性,如能够控制数据链路的建立,能够对IP地址进行分配等。PPP协议可以分为网络控制协议(NCP)和链路控制协议(LCP)。NCP用来建立和配置不同的网络层协议,需要注意的是,PPP协议允许在一条链路上传输采用多种网络层协议的数据包,而HDLC协议支持IP协议。LCP可用于启动线路,测试,任选的协商及关闭连接。目前拨号用户主要是用PPP协议,同时对租用路由器和路由线路也可以采用PPP协议。并且,可以支持多种网络层协议,而且具有验证协议CHAP和PAP,从而保证了网络的安全性。PPP的LCP选项包括认证,回拨,压缩和多链路捆绑。
          现在来看一个广域网PPP协议封装的例子。eg:某公司下属多个分公司,总公司和分公司分别设在不同的城市,为了顺利开展公司业务,要求总公司与分公司之间的网络通过路由器连接,保持网络连通。现在要在路由器上做适当配置,实现公司网内部主机互相通信。
拓扑图如下:
 
两台路由器都使用WIC-2T模块,两台路由器都要用DCE串口连接。
RA:
FA0/0:192.168.1.1 255.255.255.0
Ser0/0/0:192.168.12.1 255.255.255.0
总公司:192.168.1.10 255.255.255.0 网关:192.168.1.1
RB:
FA0/0:192.168.2.1 255.255.255.0
Ser0/0/0:192.168.12.2 255.255.255.0
总公司:192.168.2.10 255.255.255.0 网关:192.168.2.1
 
 
在RA上配置:
Router>
Router>enable
Router#configure terminal
Router(config)#hostname RA
RA(config)#line vty 0 4               —配置路由器远程登录密码
RA(config-line)#login
RA(config-line)#password 100
RA(config-line)#exit
RA(config)#enable password 100             —配置特权模式密码
RA(config)#interface fastEthernet 0/0      —进入FA0/0端口
RA(config-if)#ip address 192.168.1.1 255.255.255.0       —配置FA0/0的IP
RA(config-if)#no shutdown
RA(config-if)#exit
RA(config)#interface serial 0/0/0        —进入Ser0/0/0口
RA(config-if)#encapsulation ppp       —为端口Ser0/0/0封装PPP协议
RA(config-if)#ip address 192.168.12.1 255.255.255.0     —配置Ser0/0/0的IP
RA(config-if)#clock rate 64000     —因为Ser0/0/0端口为DCE,要配置时钟频率为64000
RA(config-if)#no shutdown
RA(config-if)#exit
RA(config)#ip route 192.168.2.0 255.255.255.0 192.168.12.2   —配置静态路由
RA(config)#
 
 
在RB上配置:
Router>
Router>enable
Router#configure terminal
Router(config)#hostname RB
RB(config)#line vty 0 4                        —配置路由器远程登录密码
RB(config-line)#login
RB(config-line)#password 100
RB(config-line)#exit
RB(config)#enable password 100             —配置特权模式密码
RB(config)#interface fastEthernet 0/0      —进入FA0/0端口
RB(config-if)#ip address 192.168.2.1 255.255.255.0     —配置FA0/0端口的IP
RB(config-if)#no shutdown
RB(config-if)#exit
RB(config)#interface serial 0/0/0             —进入Ser0/0/0口
RB(config-if)#encapsulation ppp            —为端口Ser0/0/0封装PPP协议
RB(config-if)#ip address 192.168.12.2 255.255.255.0          —配置Ser0/0/0的IP
RB(config-if)#no shutdown
RB(config-if)#exit 
RB(config)#ip route 192.168.1.0 255.255.255.0 192.168.12.1  —配置静态路由
RB(config)#exit
RB#
 
总公司PC:
分公司PC:
全部配置好了,试下能否PING通。
 
可以PING通实验成功。
 
 
         PAP和CHAP
        为了防止非法的PPP进行连接,所以PPP协议具有PAP和CHAP两种身份验证方
式,首选CHAP验证方式(安全性高)。
        PAP验证只在链路建立初期进行,只有两次信息的交换,因此被称为两次握手。PAP的验证的弱点是用户名和密码进行发送,安全性不高,优点是认证只在链路建立初期进行,节省了带宽。配置PAP协议需要在验证方和被验证方同时设置用户名和密码,且必须相同。PAP验证过程:先是被验证方发送用户名和口令到验证方,验证方对用户名和口令进行认证,根据结果返回接受或者拒绝认证请求信息,从而建立或者拒绝建立连接,此过程称为二次握手。
        CHAP验证比PAP更为安全,不只是在建立链路初期时需要验证,在链路建立后
也需要多次验证。而且,CHAP的验证过程也更为复杂,密码以密文方式发送。配置
CHAP需要在验证方和被验证方同时配置用户名和密码,并且,用户名为对方路由器名称。CHAP验证过程:先是被验证方向验证方发送用户名作为连接请求,之后,验证方向被验证方发送随机字符串。被验证方将此随机字符串和自己的密码用MD5算法加密,将密文发送到验证方。验证方将自己发出的随机字符串和被验证方的密码
同样地用MD5算法加密,将得出的口令和收到的口令进行比较,根据结果判断是接受或是拒绝连接请求。此过程被称为CHAP的认证三次握手。
        PAP与CHAP的比较。CHAP的优点是由验证方发出挑战报文才开始认证过程,可以保护验证方资源,防止拒绝服务***。MD5算法不可逆,口令即使被捕获到也无法破解,并且,在链接过程中也会做验证,验证方发送的随机字符串改变,认证口令随之改变,因此,安全性高于PAP。缺点是比较消耗网络资源。而PAP安全性差,但消耗网络资源非常少。
 
 
         现在来看两个PAP验证和CHAP验证的例子。eg:你是公司的网络管理员,公司为了满足不断增长的业务需求,申请了专线接入,你的客户端路由器与ISP进行链路协商时要验证身份,配置路由器保证链路建立,并考虑其安全性。
拓扑如如下:
 
 
(1)PAP
ISP:
Router>
Router>enable
Router#configure terminal
Router(config)#hostname ISP
ISP(config)#line vty 0 4                          —配置路由器远程登录密码
ISP(config-line)#login
ISP(config-line)#password 100
ISP(config-line)#exit
ISP(config)#enable password 100            —配置特权模式密码
ISP(config)#interface fastEthernet 0/0     —进入FA0/0端口
ISP(config-if)#ip address 192.168.1.1 255.255.255.0   —为端口FA0/0配置IP
ISP(config-if)#no shutdown
ISP(config-if)#exit
ISP(config)#interface serial 0/0/0              —进入Ser0/0/0端口
ISP(config-if)#encapsulation ppp             —为端口Ser0/0/0封装PPP协议
ISP(config-if)#ip address 192.168.12.1 255.255.255.0      —配置Ser0/0/0端口IP
ISP(config-if)#clock rate 64000           —因为Ser0/0/0端口为DCE,要设置时钟频率64000
ISP(config-if)#no shutdown
ISP(config-if)#exit
ISP(config)#username User password 0 100         —配置PAP验证的用户端用户名User及密码 “100”,启动PAP验证。
ISP(config)#int serial 0/0/0
ISP(config-if)#ppp authentication pap    —启动PAP验证
ISP(config-if)#exit
ISP(config)#ip route 192.168.2.0 255.255.255.0 192.168.12.2    —配置静态路由
ISP(config)#
 
User:
Router>
Router>enable
Router#configure terminal
Router(config)#hostname User
User(config)#line vty 0 4                                    —配置路由器远程登录密码
User(config-line)#login
User(config-line)#password 100
User(config-line)#exit
User(config)#enable password 100                 —配置特权模式密码
User(config)#interface fastEthernet 0/0         —进入FA0/0端口
User(config-if)#ip address 192.168.2.1 255.255.255.0    —为端口FA0/0配置IP
User(config-if)#no shutdown  
User(config-if)#exit
User(config)#interface serial 0/0/0                 —进入端口Ser0/0/0
User(config-if)#encapsulation ppp                —为端口Ser0/0/0端口封装PPP协议
User(config-if)#ip address 192.168.12.2 255.255.255.0   —为端口Ser0/0/0配置IP
User(config-if)#ppp pap sent-username User password 100 —设置验证用户名为User,密码为 “100”
User(config-if)#exit
User#debug ppp authentication
User#configure terminal
User(config)#ip route 192.168.1.0 255.255.255.0 192.168.12.1  —配置静态路由
User(config)#
主机0:
主机1:
 
可以PING通,PAP配置成功。
 
 
(2)CHAP
ISP:
Router>
Router>enable
Router#configure terminal
Router(config)#hostname ISP
ISP(config)#line vty 0 4                                    —配置路由器的远程登录密码
ISP(config-line)#login
ISP(config-line)#password 100
ISP(config-line)#exit
ISP(config)#enable password 100                 —配置特权模式密码
ISP(config)#interface fastEthernet 0/0          —进入FA0/0端口
ISP(config-if)#ip address 192.168.1.1 255.255.255.0    —配置端口FA0/0的IP
ISP(config-if)#no shutdown 
ISP(config-if)#exit
ISP(config)#interface serial 0/0/0                      —进去Ser0/0/0端口
ISP(config-if)#encapsulation ppp                    —为Ser0/0/0端口封装PPP协议
ISP(config-if)#ip address 192.168.12.1 255.255.255.0    —配置端口Ser0/0/0的IP
ISP(config-if)#clock rate 64000    —因为Ser0/0/0端口为DCE,要设置时钟频率64000
ISP(config-if)#no shutdown
ISP(config-if)#exit
ISP(config)#username User password 0 100        —配置CHAP验证的用户端用户名User
及密码“100”启动CHAP服务
ISP(config)#int serial 0/0/0
ISP(config-if)#ppp authentication chap       —启动CHAP验证
ISP(config-if)#exit
ISP(config)#ip route 192.168.2.0 255.255.255.0 192.168.12.2    —配置静态路由
ISP(config)#
 
User:
Router>
Router>enable
Router#configure terminal
Router(config)#hostname User
User(config)#line vty 0 4                                  —配置路由器远程登录密码
User(config-line)#login
User(config-line)#password 100
User(config-line)#exit
User(config)#enable password 100                —配置特权模式密码
User(config)#interface fastEthernet 0/0        —进入FA0/0端口
User(config-if)#ip address 192.168.2.1 255.255.255.0    —为端口FA0/0配置IP
User(config-if)#no shutdown
User(config-if)#exit
User(config)#interface serial 0/0/0                     —进入Ser0/0/0端口
User(config-if)#encapsulation ppp                    —端口Ser0/0/0封装PPP协议
User(config-if)#ip address 192.168.12.2 255.255.255.0  —配置Ser0/0/0的IP
User(config-if)#no shutdown
User(config-if)#exit
User(config)#username ISP password 0 100  —设置CHAP验证的验证方用户名为ISP
自己的密码:“100”要求与对方密码保持一致。
User(config)#exit
User#debug ppp authentication
User#configure terminal
User(config)#ip route 192.168.1.0 255.255.255.0 192.168.12.1 —配置静态路由
User(config)#
主机0:
主机1:
可以PING通,CHAP验证试验成功。
 
 
 
 
 
PS:有半个多月没有来了,烦心的事终于去全过去了,从阴影中走出来了,现在继续奋斗。