30-廣域網——PPP協議和安全認證

1. PPP協議

雖然在廣域網中點對點通信的技術有很多,但是HDLC技術已經很少使用了,目前使用最廣泛的還是PPP協議。ppp協議通過在以太網上提供點到點連接,建立PPP會話,可以讓一個主機接入遠端的因特網,並通過PPP協議對每個接入的主機進行控制,具有更高的安全性。

 

PPP協議早在1994年就成爲了因特網的正式標準,不同廠商的網絡設備都支持PPP協議,可以實現不同廠商的網絡設備點對點通信,PPP協議也是工作在鏈路層,它主要有以下幾個功能:

  1. 點對點數據封裝成幀
  2. 用戶認證
  3. 鏈路捆綁
  4. 數據壓縮

 

2. 封裝成幀

點對點通信中,鏈路層是封裝PPP協議進行通信的。

 

R1設備配置IP地址並開啓PPP協議封裝:

R1#conf t
R1(config)#int s0/0
//開啓PPP協議封裝
R1(config-if)#encapsulation ppp 
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config-if)#no shutdown 
R1(config-if)#exit
R1(config)#

 

 

R2設備配置IP地址並開啓PPP協議封裝:

R2#conf t
R2(config)#int s0/0
//開啓PPP協議封裝
R2(config-if)#encapsulation ppp 
R2(config-if)#no shutdown 
R2(config-if)#ip address 12.1.1.2 255.255.255.0
R2(config-if)#exit
R2(config)#exit

 

 

通過wireshark抓取R1和R2設備的PPP協議:

默認情況下,R1和R2每10秒就會發送一個基於LCP協議的PPP協議數據包,通常是一個請求包對應一個響應包,用於維護這條鏈路的通信。也就是說,通過這個基於LCP的PPP協議包也可以來判斷這條鏈路是否出現通信故障。

 

PPP協議主要由LCP協議和NCP協議組成:

  1. LCP協議(Link Control Protocol):鏈路控制協議,用來建立,配置和維護數據鏈路層通信的,實現通信雙方的鏈路協商。
  2. NCP協議(Network Control Protocol):網絡控制協議,NCP協議中的每一個協議支持不同的網絡層協議,例如:IP,IPv6,AppleTalk等,簡單來講就是用於支持不同網絡層協議。

 

3. PPP安全認證

PPP協議通過安全認證協議對每個接入因特網的主機設備進行控制,具有更高的安全性,PPP的安全認證技術主要有以下兩種:

  1. PAP認證
  2. CHAP認證

 

 

3.1 PAP認證

PAP(Password Authentication Protocol,簡稱PAP)協議在PPP鏈路的基礎上利用2次握手的簡單方法進行認證,源節點會在ppp連路上反覆發送用戶名和密碼,直到驗證通過。但是在實際的網絡環境中是不推薦使用PAP進行用戶安全認證的,因爲PAP認證的用戶名和密碼在鏈路上是以明文的形式傳輸,由於是源節點控制驗證的頻率和次數,因此PAP認證不能防範一些重複性的網絡攻擊。

總之PAP認證的特點就是:明文認證,兩次握手,單向認證。

 

 

PAP認證實驗步驟:

1. 首先client和server部署ppp協議,建立ppp鏈路

2. 然後Server設置PAP認證用戶名和密碼,Client進行PAP驗證

3. wireshark抓取PAP認證協議包

 

 

Server配置ip地址並部署ppp協議,以建立ppp鏈路,配置如下:

Server#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Server(config)#int s0/0
Server(config-if)#no shutdown 
Server(config-if)#ip address 12.1.1.2 255.255.255.0
Server(config-if)#encapsulation ppp 
Server(config-if)#

 

 

Client配置如下:
 

Client#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Client(config)#int s0/0
Client(config-if)#no shutdown 
*Mar  1 00:03:06.323: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up12
*Mar  1 00:03:07.327: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
Client(config-if)#ip address 12.1.1.1 255.255.255.0
Client(config-if)#encapsulation ppp 
Client(config-if)#

 

 

Serve設置PAP認證並設置用戶名和密碼,配置如下:

Server(config)#username test password 123456
Server(config)#int s0/0
Server(config-if)#ppp authentication pap
Server(config-if)#
*Mar  1 00:04:51.751: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down
Server(config-if)#

 

 

由於此時Client還沒有向Server進行PAP認證,所以Client和Server是無法通信的:

Client#ping 12.1.1.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

 

 

然後Client向Server進行PAP認證,配置如下:

Client#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Client(config)#int s0/0
//發送認證的用戶名和密碼
Client(config-if)#ppp pap sent-username test pass
Client(config-if)#end
Client#
Client#ping 12.1.1.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/32/40 ms
Client#      

當Client向Server進行PAP認證通過後,Client和Server之間就可以進行點對點通信了。
 

 

 

wireshark抓取Client和Server認證的PAP數據包:

從wireshark中可以看到Client向Server驗證時發送的PAP協議的兩次握手過程,並且在數據包中攜帶的用戶名和密碼是以明文傳輸的(PAP認證是明文傳輸),這對於網絡安全問題越來越突出的情況下,PAP認證是非常不安全的,不推薦使用。

 

3.2 CHAP認證

CHAP(Challenge Handshake Authentication Protocol,簡稱CHAP)協議中文爲詢問握手驗證協議 ,CHAP協議也是基於PPP鏈路的,在建立PPP鏈路後利用3次握手週期性的進行驗證,CHAP協議不允許連接發起方在沒有收到任何詢問消息(hello包)下進行驗證嘗試。CHAP協議每次使用不同的詢問消息,每個消息都是不可預測的唯一的值,並且該詢問消息經過MD5加密運算後的加密值提高了安全性,可以防止一些網絡攻擊,因此CHAP比PAP具有更高的安全性。

 

CHAP認證的特點:

  1. 比PAP認證更加安全
  2. 三次握手
  3. 雙向認證

R1和R2開啓CHAP認證之前,先配置ip地址,部署PPP協議。

 

 

R1開啓CHAP認證,用戶名爲R2,密碼爲cisco,配置如下:

R1(config)#username R2 password cisco
R1(config)#int s0/0
R1(config-if)#ppp authentication chap
R1(config-if)#exit

 

R2開啓CHAP認證,配置如下:

R2(config)#username R1 password cisco
R2(config)#int s0/0
R2(config-if)#ppp authentication chap
R2(config-if)#exit 

 

 

Wireshark抓取R1和R2的CHAP認證包:

 

4. 鏈路捆綁

PPP協議裏的鏈路捆綁跟Etherchannel技術中的鏈路捆綁是類似相通的,這裏直接開始PPP鏈路捆綁的配置。

 

 

R1設備設置S0/0口和s0/1口的PPP鏈路捆綁,配置如下:

R1(config)#int s0/0
R1(config-if)#no shutdown 
R1(config-if)#encapsulation ppp
R1(config-if)#ppp multilink 
R1(config-if)#ppp multilink group 1
R1(config-if)#
R1(config)#int s0/1
R1(config-if)#no shutdown 
R1(config-if)#encapsulation ppp
R1(config-if)#
*Mar  1 00:11:25.147: %LINK-3-UPDOWN: Interface Serial0/1, changed state to up   
R1(config-if)#ppp multilink 
R1(config-if)#ppp multilink group 1

將接口放入捆綁組group 1當中,這裏的group用於區分本地多個捆綁組,是本地標識,把s0/0和s0/1接口放入group 1組當中

 

 

 

R2設備設置S0/0口和s0/1口的PPP鏈路捆綁,配置如下:

R2(config)#int s0/0
R2(config-if)#no shutdown 
R2(config-if)#encapsulation ppp
R2(config-if)#ppp multilink 
*Mar  1 00:11:34.491: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, chang                
R2(config-if)#ppp multilink group 1
R2(config-if)#
R2(config)#int s0/1
R2(config-if)#no shutdown 
R2(config-if)#encapsulation ppp
R2(config-if)#ppp multilink 
R2(config-if)#ppp multilink group 1
R2(config-if)#

 

給R1設備的邏輯鏈路捆綁的接口配置IP地址:

R1(config)#int multilink 1       
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#

 

 

給R2設備的邏輯鏈路捆綁的接口配置IP地址:

R2(config)#int multilink 1
R2(config-if)#ip address 12.1.1.2 255.255.255.0
R2(config-if)#exit
R2(config)#

 

 

 

查看R1設備的PPP鏈路捆綁狀態:

R1#show interfaces multilink 1
Multilink1 is up, line protocol is up 
  Hardware is multilink group interface
  Internet address is 12.1.1.1/24
//可以看到R1設備的s0/0口和s0/1口捆綁成一條鏈路了
  MTU 1500 bytes, BW 3088 Kbit, DLY 100000 usec, 
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation PPP, LCP Open, multilink Open
  Open: IPCP, CDPCP, loopback not set
  Keepalive set (10 sec)
  DTR is pulsed for 2 seconds on reset
  Last input 00:00:40, output never, output hang never
  Last clearing of "show interface" counters 00:02:11
  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: fifo
  Output queue: 0/40 (size/max)
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
     7 packets input, 676 bytes, 0 no buffer
     Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
     7 packets output, 728 bytes, 0 underruns
     0 output errors, 0 collisions, 1 interface resets
     0 output buffer failures, 0 output buffers swapped out
     0 carrier transitions
R1#

 

 

查看R1設備的邏輯捆綁鏈路接口信息:

R1#show ip interface brief 
Interface                  IP-Address      OK? Method Status                Protocol
Serial0/0                  unassigned      YES TFTP   up                    up      
Serial0/1                  unassigned      YES NVRAM  up                    up      
Serial0/2                  unassigned      YES NVRAM  administratively down down    
Serial0/3                  unassigned      YES NVRAM  administratively down down    
Multilink1                 12.1.1.1        YES manual up                    up      
R1#

 

 

測試R1和R2的網絡連通性:

R1#ping 12.1.1.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 48/65/72 ms
R1#

到此,說明PPP協議鏈路捆綁實驗完成。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章