了解 PPPOE
更新記錄
item | note |
---|---|
20160725 | 第一版 |
目錄
PPP
- The Point-to-Point Protocol (PPP) provides a standard way to establish a network connection over a serial link
- 由user space (pppd)及相關的kernel(pppoe kernel config)來完成
- This PPP implementation consists of two parts:
- Kernel code
- The PPP daemon (pppd)
Pppd includes support for authentication
pppoe kernel 設定
- 以hisi 3535為例子(kernel 3.8.x)需要開啟下例kernel選項 configs/hi3535_full_slave_defconfig
1 | 985 CONFIG_PPP=y |
- kernel config
item | note | local |
---|---|---|
PPP | point-to-point protocol support | driver/net/ppp |
PPPOE | PPP over Ethernet | driver/net/ppp |
PPP_FILETER | PPP filter | driver/net/ppp |
CONFIG_SLHC | 此設定是相依PPP,因此會自動開啟 |
PPPOE撥號程序
主要分為2個階段
- 發現(Discovery)階段
- 會話階段
PPPOE溝通程序如下圖
來源:基于嵌入式 Linux 的 PPPoE 实现
PPP 發現(Discovery)階段
- client發出broadcast(255.255.255.255)的PADI
已時seesion id為0 - server 回應PADO,此時pppoe_tag(AC-Name: CHCH-BRAS-2221)
- 經過了PADR之後,server將會回應PADS,此時會取得session-id,完成Discovery過程
PPP會話階段
- 一旦PPPoE會話開始,PPP數據就可以以任何其它的PPP封裝形式發送
PPPOE Wireshark log
- wireshark log
- step flow
step | note |
---|---|
PPPoED | C->S , PADI: Active Discovery Initiation |
S->C , PADO: Active Discovery Offer | |
C >S , PADR: Active Discovery Request | |
S->C , PADS: Active Discovery Session-confirmation (發現階段完成) | |
PPP LCP | C->S , Configuration Reuest |
.. | .. |
PPP LCP | C->S , Echo Request |
PPP PAP | C->S, Authenticate-Request (帶撥號帳密) |
PPP IPCP | S->C, Configuration Reuqst |
- PPPoED, PPP over Ethernet Discovery
- PPP LCP, PPP Link Control Protocol
- PPP PAP, PPP Password Authentication Protocol
PPP IPCP, PPP IP control Protocol
PADS pkt
此時最低層為PPPOE
- PPP LCP pkt
此時最低層為PPP
如何以pppd來撥號
pppd取得
- ppp-2.4.7.tar.gz download
- Cross Compiling Kernel Mode PPPoE & PPPD for ARM
1 | cd ppp-2.4.7/ |
- 取得pppd及rp-pppoe.so
pppd 撥號
1 | pppd plugin /usr/lib/rp-pppoe.so eth0 user 7476xxx@hinet.net password wicpzcdkz persist usepeerdns defaultroute unit 2 |
pppd 指令說明
pppd [ options ]
plugin filename
- Load the shared library object file filename as a plugin.
- If filename does not contain a slash (/), pppd will look in the /usr/lib/pppd/version directory for the plugin.
user name
- Sets the name used for authenticating the local system to the peer to name.
password password-string
- Specifies the password to use for authenticating to the peer
persist
- Do not exit after a connection is terminated; instead try to reopen the connection.
usepeerdns
- Ask the peer for up to 2 DNS server addresses.
defaultroute
- Add a default route to the system routing tables, using the peer as the gateway, when IPCP negotiation is successfully completed.
unit num
- Sets the ppp unit number (for a ppp0 or ppp1 etc interface name) for outbound connections.
flow
state machine流程
其它
以手動方式建立 PPP 連結">以手動方式建立 PPP 連結
pppd -d -detach /dev/ttySx 38400 &
1 | -d 這個選項開啟偵錯功能 - ppp 連線起動時的”交談”將會記錄到你的系統記錄裡去 - 如果你遇上麻煩這會很有用的. |
ifconfig ppp
1 | ppp2 Link encap:Point-to-Point Protocol |
- inet addr: 表示你取得ip
- P-t-P: 伺服端的 IP 號碼
參考來源
- PPP HOWTO 中譯版
- PPP
- 以手動方式建立 PPP 連結
- man pppd
- Cross Compiling Kernel Mode PPPoE & PPPD for ARM
- local: 基于嵌入式 Linux 的 PPPoE 实现
A Method for Transmitting PPP Over Ethernet (PPPoE) RFC2561
-PPPoE has two distinct stages. There is a Discovery stage and a PPP Session stage- The Discovery stage remains stateless until a PPP session is established
- Once a PPP session is established, both the Host and the Access Concentrator MUST allocate the resources for a PPP virtual interface