PPPoE Server是端利用/etc/ppp下的ipv6-up/ipv6-down來轉發v6 IP給client 要轉發v6 ip主要是透過radvd. 如果需要發送dns資訊, 則需要透過dhcpv6, 目前可用的PPP over dhcpv6只有tchdpd能用.
程式下載
- apt-get install radvd
- apt-get install pppoe
參數設定
編輯/etc/ppp/pppoe-server-options:
#require-chap require-pap lcp-echo-interval 10 lcp-echo-failure 2 ipv6 , 逗號前面要有一個空格
編輯/etc/ppp/options:(以我現有的作範例)
asyncmap 0 noauth crtscts lock hide-password modem +pap -chap proxyarp lcp-echo-interval 30 lcp-echo-failure 4 noipx
建立目錄/etc/ppp/ipv6-radvd
建立ipv6-up script:/etc/ppp/ipv6-up
#!/bin/sh # These variables are for the use of the scripts run by run-parts. PPP_IFACE="$1" PPP_TTY="$2" PPP_SPEED="$3" PPP_LOCAL="$4" PPP_REMOTE="$5" PPP_IPPARAM="$6" export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM # The environment is cleared before executing this script. PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin export PATH # If /var/log/ppp-ipupdown.log exists use it for logging. if [ -e /var/log/ppp-ipupdown.log ]; then exec >> /var/log/ppp-ipupdown.log 2>&1 fi # This script can be used to override the .d files supplied by other packages. if [ -x /etc/ppp/ipv6-up.local ]; then exec /etc/ppp/ipv6-up.local "$*" fi run-parts /etc/ppp/ipv6-up.d \ --arg="$1" --arg="$2" --arg="$3" --arg="$4" --arg="$5" --arg="$6" # if pon was called with the "quick" argument, stop pppd if [ -e /var/run/ppp-quick ]; then rm /var/run/ppp-quick wait kill $PPPD_PID fi
建立檔案/etc/ppp/ipv6-up.d/radvd
#!/bin/sh ADDR=$(echo $PPP_REMOTE | cut -d : -f 3,4,5,6) if test x$ADDR == x ; then echo "Unable to generate IPv6 address" exit 0 fi ADDR=2001:470:8192:BEEF:$ADDR #add route route -6 add $ADDR/128 dev $PPP_IFACE #generate radvd config RAP=/etc/ppp/ipv6-radvd/$PPP_IFACE RA=$RAP.conf cat <$RA interface $PPP_IFACE{ AdvManagedFlag off; AdvOtherConfigFlag on; AdvSendAdvert on; MinRtrAdvInterval 5; MaxRtrAdvInterval 100; UnicastOnly on; AdvSourceLLAddress on; prefix 2001:470:8192:BEEF::/64 {}; }; EOF #start radvd /usr/sbin/radvd -C $RA -p $RAP.pid #如果有dhcpv6, 則在此加tchdpd的資訊 #start tchdpd /usr/sbin/tdhcpd --dns-server=2001:470:20::2 --dns-name=$PPP_IFACE.tunnel.ipv6.icybear.net --pid-file=$RAP.dhcp.pid --local-id=test --log-level=debug $PPP_IFACE # --local-id=tunnel.ipv6.icybear.net -L debug\ #update dns ARPA=$(ipv6_rev $ADDR) nsupdate << EOF update delete $ARPA update add $ARPA 10 ptr $PPP_IFACE.tunnel.ipv6.icybear.net send update delete $PPP_IFACE.tunnel.ipv6.icybear.net update add $PPP_IFACE.tunnel.ipv6.icybear.net 10 aaaa $ADDR send EOF exit 0
建立ipv6-down script:/etc/ppp/ipv6-down
#!/bin/sh # These variables are for the use of the scripts run by run-parts. PPP_IFACE="$1" PPP_TTY="$2" PPP_SPEED="$3" PPP_LOCAL="$4" PPP_REMOTE="$5" PPP_IPPARAM="$6" export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM # The environment is cleared before executing this script. PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin export PATH # If /var/log/ppp-ipupdown.log exists use it for logging. if [ -e /var/log/ppp-ipupdown.log ]; then exec >> /var/log/ppp-ipupdown.log 2>&1 fi # This script can be used to override the .d files supplied by other packages. if [ -x /etc/ppp/ipv6-down.local ]; then exec /etc/ppp/ipv6-down.local "$*" fi run-parts /etc/ppp/ipv6-down.d \ --arg="$1" --arg="$2" --arg="$3" --arg="$4" --arg="$5" --arg="$6"
建立檔案/etc/ppp/ipv6-down.d/radvd
#!/bin/sh RAP=/etc/ppp/ipv6-radvd/$PPP_IFACE kill `cat $RAP.pid` || true kill `cat $RAP.dhcp.pid` || true rm -f $RAP.* ADDR=$(echo $PPP_REMOTE | cut -d : -f 3,4,5,6) ADDR=2001:470:8192:BEEF:$ADDR ARPA=$(ipv6_rev $ADDR) nsupdate << EOF update delete $ARPA send update delete $PPP_IFACE.tunnel.ipv6.icybear.net send EOF exit 0
修改帳號資訊檔/etc/ppp/pap-secrets or chap-secrets
加入 "test" * "test" * 中間用tab鍵隔開 撥號時使用test/test作連接
執行Server:pppoe-server -F -l eth0 -L 192.192.192.200 -R 192.192.192.201 -N 10
Client端
程式下載
- libpcap http://www.tcpdump.org/
- pppd http://ppp.samba.org/
- rp-pppoe http://www.roaringpenguin.com/products/pppoe
kernel options
Device Drivers->Network Device Support->PPP Support (PPP support for async serial ports, PPP support for sync tty ports必選, 其它看情況)
Device Drivers->Network Device Support->Universal TUN/TAP device driver support (PPP在連接時是利用/dev/net/tun)
libpcap
1.下載程式碼 http://www.tcpdump.org/release/libpcap-1.1.1.tar.gz
2. tar zxvf libpcap-1.1.1.tar.gz; cd libpcap-1.1.1
3. ./configure --host=arm-none-linux-gnueabi --with-pcap=null && make && make install
pppd2. tar zxvf libpcap-1.1.1.tar.gz; cd libpcap-1.1.1
3. ./configure --host=arm-none-linux-gnueabi --with-pcap=null && make && make install
1.下載程式碼 git clone git://git.ozlabs.org/~paulus/ppp.git
2.編輯 ppp/pppd/Makefile.linux:
<1>打開 HAVE_INET6=y
<2>
ifdef FILTER
ifneq ($(wildcard /usr/include/pcap-bpf.h),)
改成安裝pcap的目錄
ifneq ($(wildcard /home/shaw/work/qemu/src/toolchain/lib/sysroot/usr/include/pcap-bpf.h),)
LIBS += -lpcap
CFLAGS += -DPPP_FILTER
增加
CFLAGS += -DPPP_FILTER -I/home/shaw/work/qemu/src/toolchain/usr/include -L/home/shaw/work/qemu/src/toolchain/usr/lib
3. ./configure && make CC=arm-none-linux-gnueabi && cp pppd/pppd target_dir
rp-pppoe2.編輯 ppp/pppd/Makefile.linux:
<1>打開 HAVE_INET6=y
<2>
ifdef FILTER
ifneq ($(wildcard /usr/include/pcap-bpf.h),)
改成安裝pcap的目錄
ifneq ($(wildcard /home/shaw/work/qemu/src/toolchain/lib/sysroot/usr/include/pcap-bpf.h),)
LIBS += -lpcap
CFLAGS += -DPPP_FILTER
增加
CFLAGS += -DPPP_FILTER -I/home/shaw/work/qemu/src/toolchain/usr/include -L/home/shaw/work/qemu/src/toolchain/usr/lib
3. ./configure && make CC=arm-none-linux-gnueabi && cp pppd/pppd target_dir
1.下載程式碼 http://www.roaringpenguin.com/files/download/rp-pppoe-3.10.tar.gz
2. tar zxvf rp-pppoe-3.10.tar.gz && cd rp-pppoe-3.10
3. ./configure
4. sed -i 's/gcc/arm-none-linux-gnueabi-gcc/g' Makefile && sed -i 's/gcc/arm-none-linux-gnueabi-gcc/g' libevent/Makefile
5. make && cp src/pppoe target_dir
6.將./configs下的文件copy到target的/etc/ppp/,並開啟write權限
7.將./scripts下的文件copy到target的/sbin,並修改其中內容使能順利在板子上執行
2. tar zxvf rp-pppoe-3.10.tar.gz && cd rp-pppoe-3.10
3. ./configure
4. sed -i 's/gcc/arm-none-linux-gnueabi-gcc/g' Makefile && sed -i 's/gcc/arm-none-linux-gnueabi-gcc/g' libevent/Makefile
5. make && cp src/pppoe target_dir
6.將./configs下的文件copy到target的/etc/ppp/,並開啟write權限
7.將./scripts下的文件copy到target的/sbin,並修改其中內容使能順利在板子上執行
參數設定
pppoe連接主要是靠pppd+pppoe程式和Server進行連結.
設定檔主要會放在/etc/ppp/
要啟動pppoe的話, 必須先讓eth0 up, 再輸入
/* 產生設定檔 */
pppoe-setup
/* 執行 */
pppoe-start
如果要執行IPv6, 要在pppoe.conf中加入PPPD_EXTRA="ipv6 ,"pppoe-setup
/* 執行 */
pppoe-start
逗號前面要有一個空格
最後輸入ifconfig 看ppp0有沒有被啟動 & 設定ip