pppoe

了解 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
2
3
4
5
6
7
8
9
10
11
12
13
985 CONFIG_PPP=y
986 # CONFIG_PPP_BSDCOMP is not set
987 # CONFIG_PPP_DEFLATE is not set
988 CONFIG_PPP_FILTER=y
989 # CONFIG_PPP_MPPE is not set
990 CONFIG_PPP_MULTILINK=y
991 CONFIG_PPPOE=y
992 # CONFIG_PPPOLAC is not set
993 # CONFIG_PPPOPNS is not set
994 # CONFIG_PPP_ASYNC is not set
995 # CONFIG_PPP_SYNC_TTY is not set
996 # CONFIG_SLIP is not set
997 CONFIG_SLHC=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溝通程序如下圖

[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
[PPPOE]
  • 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

[PADS]
  • PPP LCP pkt
    此時最低層為PPP[PPP LCP]

如何以pppd來撥號

pppd取得

1
2
3
cd ppp-2.4.7/
./configure
make CC=arm-hisiv200-linux-gcc
  • 取得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流程

[PPPOE]

其它

以手動方式建立 PPP 連結">以手動方式建立 PPP 連結

pppd -d -detach /dev/ttySx 38400 &

1
-d 這個選項開啟偵錯功能 - ppp 連線起動時的”交談”將會記錄到你的系統記錄裡去 - 如果你遇上麻煩這會很有用的.

ifconfig ppp

1
2
3
4
5
6
7
ppp2      Link encap:Point-to-Point Protocol  
inet addr:111.246.133.159 P-t-P:168.95.98.254 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:4240 errors:0 dropped:0 overruns:0 frame:0
TX packets:4536 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:304494 (297.3 KiB) TX bytes:309494 (302.2 KiB)
  • inet addr: 表示你取得ip
  • P-t-P: 伺服端的 IP 號碼

參考來源