PPPoE簡介介紹及配置
簡介:
PPPoE(PPP over Ethernet)協議是一種把PPP幀封裝到乙太網幀中的鏈路層協議。PPPoE可以使乙太網網路中的多臺主機連線到遠端的寬頻接入伺服器。
目的:
運營商希望把一個站點上的多臺主機連線到同一臺遠端接入裝置,同時接入裝置能夠提供與撥號上網類似的訪問控制和計費功能。在眾多的接入技術中,把多個主機連線到接入裝置的最經濟的方法就是乙太網,而PPP協議可以提供良好的訪問控制和計費功能,於是產生了在乙太網上傳輸PPP報文的技術,即PPPoE。
PPPoE利用乙太網將大量主機組成網路,通過一個遠端接入裝置連入因特網,並運用PPP協議對接入的每個主機進行控制,具有適用範圍廣、安全性高、計費方便的特點。
PPPoE典型組網:
PPPoE組網結構採用Client/Server模型,PPPoE的客戶端為PPPoE Client,PPPoE的伺服器端為PPPoE Server。PPPoE Client向PPPoE Server發起連線請求,PPPoE Server為PPPoE Client提供接入控制、認證等功能。
常見企業或者家庭組網模式:路由器裝置作為PPPoE Client:
Router A作為PPPoE Client下行連線區域網使用者,Router B是運營商的裝置。所有主機不用安裝PPPoE Client撥號軟體,同一個區域網中的所有主機共享一個賬號,通過
PPPoE撥號的工作原理:
PPPoE撥號是為了實現PPPoE Client與PPPoE Server之間的連線,建立PPPoE會話。
PPPoE撥號可分為三個階段,即Discovery階段、Session階段和Terminate階段。
如下圖:
Discovery階段由四個過程組成。
1.PPPoE Client廣播發送一個PADI(PPPoE Active Discovery Initial)報文,在此報文中包含PPPoE Client想要得到的服務型別資訊。
2.所有的PPPoE Server收到PADI報文之後,將其中請求的服務與自己能夠提供的服務進行比較,如果可以提供,則單播回覆一個PADO(PPPoE Active Discovery Offer)報文。
3.根據網路的拓撲結構,PPPoE Client可能收到多個PPPoE Server傳送的PADO報文,PPPoE Client選擇最先收到的PADO報文對應的PPPoE Server做為自己的PPPoE Server,並單播發送一個PADR(PPPoE Active Discovery Request)報文。
4.PPPoE Server產生一個唯一的會話ID(Session ID),標識和PPPoE Client的這個會話,通過傳送一個PADS(PPPoE Active Discovery Session-confirmation)報文把會話ID傳送給PPPoE Client,會話建立成功後便進入PPPoE Session階段。
完成之後通訊雙方都會知道PPPoE的Session_ID以及對方的乙太網地址,它們共同確定了唯一的PPPoE Session。
Session階段:
PPPoE Session階段可劃分為兩部分,一是PPP協商階段,二是PPP資料傳輸階段。
PPPoE Session上的PPP協商和普通的PPP協商方式一致,分為LCP、認證、NCP三個階段。
1.LCP階段主要完成建立、配置和檢測資料鏈路連線。
2.LCP協商成功後,開始進行認證,認證協議型別由LCP協商結果(CHAP或者PAP)決定。
3.認證成功後,PPP進入NCP階段。NCP是一個協議族,用於配置不同的網路層協議,常用的是IP控制協議(IPCP),它主要負責協商使用者的IP地址和DNS伺服器地址。
PPPoE Session的PPP協商成功後,就可以承載PPP資料報文。
在PPPoE Session階段所有的乙太網資料包都是單播發送的。
Terminate階段:
PPP通訊雙方可以使用PPP協議自身來結束PPPoE會話,當無法使用PPP協議結束會話時可以使用PADT(PPPoE Active Discovery Terminate)報文。
進入PPPoE Session階段後,PPPoE Client和PPPoE Server都可以通過傳送PADT報文的方式來結束PPPoE連線。PADT資料包可以在會話建立以後的任意時刻單播發送。在傳送或接收到PADT後,就不允許再使用該會話傳送PPP流量了。
拓撲:
配置:
R1(config)#host Server
Server(config)#username qytang password cisco //裝置本地使用者資料庫
Server(config)#ip local pool PPPOE_POOL 201.100.98.42 //設定本地地址池
Server(config)#int virtual-template 1 //設定虛擬模版
Server(config-if)#ip add 201.100.98.41 255.255.255.252 //配置IP地址,模擬公網地址
Server(config-if)#peer default ip address pool PPPOE_POOL //呼叫本地地址池
Server(config-if)#ppp authentication chap //設定CHAP認證
Server(config)#bba-group pppoe CISCO //設定bba-group
Server(config-bba-group)#virtual-template 1 //呼叫虛擬模版
Server(config)#int e0/0
Server(config-if)#pppoe enable group CISCO //介面呼叫bba-group
Server(config-if)#no shut
Client:
R2(config)#host Client
Client(config)#int dialer 1 //撥號介面1
Client(config-if)#ip add negotiated //地址自動協商
Client(config-if)#encapsulation ppp //封裝模式PPP
Client(config-if)#ppp chap hostname qytang //CHAP認證使用者名稱
Client(config-if)#ppp chap password cisco //CHAP認證密碼
Client(config)#int e0/0
Client(config-if)#pppoe-client dial-pool-number 1 //呼叫撥號介面1
Client(config-if)#no shut
Server#show ip int b
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 unassigned YES unset up up
Ethernet0/1 unassigned YES unset administratively down down
Ethernet0/2 unassigned YES unset administratively down down
Ethernet0/3 unassigned YES unset administratively down down
Virtual-Access1 unassigned YES unset down down
Virtual-Access2 unassigned YES unset up up
Virtual-Access2.1 201.100.98.41 YES manual up up
Virtual-Template1 201.100.98.41 YES manual down down
Client#show ip int b
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 unassigned YES unset up up
Ethernet0/1 unassigned YES unset administratively down down
Ethernet0/2 unassigned YES unset administratively down down
Ethernet0/3 unassigned YES unset administratively down down
Dialer1 201.100.98.42 YES IPCP up up
Virtual-Access1 unassigned YES unset up up
Server#show ppp all //檢視PPP協商認證
Interface/ID OPEN+ Nego* Fail- Stage Peer Address Peer Name
------------ --------------------- -------- --------------- --------------------
Vi2.1 LCP+ CHAP+ IPCP+ LocalT 201.100.98.42 qytang
Server#
Server#show pppoe session //檢視PPPOE會話
1 session in LOCALLY_TERMINATED (PTA) State
1 session total
Uniq ID PPPoE RemMAC Port VT VA State
SID LocMAC VA-st Type
2 2 aabb.cc00.2000 Et0/0 1 Vi2.1 PTA
aabb.cc00.1000 UP
Server#
測試:
Client#ping 201.100.98.41
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 201.100.98.41, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Server#
*Dec 3 08:29:39.255: PPPoE 0: I PADI R:aabb.cc00.2000 L:ffff.ffff.ffff Et0/0
*Dec 3 08:29:39.255: Service tag: NULL Tag
*Dec 3 08:29:39.255: PPPoE 0: O PADO, R:aabb.cc00.1000 L:aabb.cc00.2000 Et0/0
*Dec 3 08:29:39.255: Service tag: NULL Tag
Server#
*Dec 3 08:29:41.341: PPPoE 0: I PADR R:aabb.cc00.2000 L:aabb.cc00.1000 Et0/0
*Dec 3 08:29:41.341: Service tag: NULL Tag
*Dec 3 08:29:41.341: PPPoE : encap string prepared
*Dec 3 08:29:41.341: [2]PPPoE 2: Access IE handle allocated
*Dec 3 08:29:41.341: [2]PPPoE 2: AAA unique ID E allocated
*Dec 3 08:29:41.341: [2]PPPoE 2: No AAA accounting method list
*Dec 3 08:29:41.341: [2]PPPoE 2: Service request sent to SSS
*Dec 3 08:29:41.341: [2]PPPoE 2: Created, Service: None R:aabb.cc00.1000 L:aabb.cc00.2000 Et0/0
*Dec 3 08:29:41.341: [2]PPPoE 2: State NAS_PORT_POLICY_INQUIRY Event SSS MORE KEYS
*Dec 3 08:29:41.345: [2]PPPoE 2: data path set to PPP
*Dec 3 08:29:41.346: [2]PPPoE 2: Segment (SSS class): PROVISION
*Dec 3 08:29:41.346: [2]PPPoE 2: State PROVISION_PPP Event SSM PROVISIONED
*Dec 3 08:29:41.346: [2]PPPoE 2: O PADS R:aabb.cc00.2000 L:aabb.cc00.1000 Et0/0
*Dec 3 08:29:41.390: [2]PPPoE 2: State LCP_NEGOTIATION Event SSS CONNECT LOCAL
*Dec 3 08:29:41.398: [2]PPPoE 2: Segment (SSS class): UPDATED
*Dec 3 08:29:41.398: [2]PPPoE 2: Segment (SSS class): BOUND
*Dec 3 08:29:41.398: [2]PPPoE 2: data path set to Virtual Acess
*Dec 3 08:29:41.398: [2]PPPoE 2: State LCP_NEGOTIATION Event SSM UPDATED
*Dec 3 08:29:41.398: [2]PPPoE 2: State PTA_BINDING Event STATIC BIND RESPONSE
Server#
*Dec 3 08:29:41.398: [2]PPPoE 2: Connected PTA
*Dec 3 08:29:41.432: PPPoE : ipfib_encapstr prepared
Server#
通過wireshark抓包顯示如下:
PPPoE優化:
二次封裝耗費資源,降低了傳輸效能
MTU1492:
乙太網最大負載1500,pppoe頭為6位元組,PPP協議為2位元組,而整個二層幀為1518,那麼PPPoE的MTU=1518-18-6-2=1492位元組
MSS(Maxitum Segment Size )是TCP資料包每次能夠傳輸的最大資料分段。為了達到最佳的傳輸效能TCP協議在建立連線的時候通常要協商雙方的MSS值,這個值TCP協議在實現的時候為1460
interface Dialer1
ip mtu 1492 //修改 MTU 為1492
ip tcp adjust-mss 1452 //修改最大資料分段大小為1452 MSS=1500byte-IP 20byte-tcp 20byte- pppoe 6byte-ppp 2byte=1452