Personal email:Xiaokeweng@gmail.com
The basic service that satisfies the pppoe connection is to ensure that the ppp protocol can be encapsulated in the Ethernet framework. Because the ppp protocol is integrated, therefore, it is achieved that VPC cannot provide authentication, encryption, and compression functions. Essentially, it is a ppp protocol tunnel that allows two Ethernet interfaces in the Ethernet broadcast domain to be created. It uses traditional PPP-based software to manage a connection that uses Ethernet-like directed packet network instead of a serial line. This standard connection with login and password makes it easy to charge fees for suppliers. In addition, IP addresses are allocated only when the other end of the connection is connected to PPPoE, so dynamic reuse of IP addresses is allowed.
--- Wiki:
Http://zh.wikipedia.org/zh-cn/PPPoE
(PPPoE and TCP/IP protocol stack)
(1) pppoe-server
That is, the PC machine. Here I only talk about the situation under the linux system. My Ubuntu system is used. Download rp-pppoe:
Http://www.roaringpenguin.com/products/pppoe
Install rp-pppoe according to README requirements. The simplest is to run the go script directly by default. Then the PC machine can run the pppoe-server command. Do not rush, but also Configure the server. The configuration file is in/etc/pppoe-server-options and is opened for rewriting. My configuration is as follows:
# PPP options for the PPPoE server # LIC: GPLauth # verify require-chap # CHAP authentication # login # verify lcp-echo-interval 10 # Send heartbeat signaling requestlcp-echo-failure 2 # two consecutive heartbeats signaling reply no reply disconnect
Save and exit, and the configuration is complete. In this way, verification will be performed during the Discovery stage when the ppp link is established. The authentication username and password saved by the server are in/etc/ppp/chap-secrets:
# Secrets for authentication using CHAP# client server secret IP addresses "user_xiaokeweng" * "my_password" *
The meaning of each field, as the name suggests, * indicates all.
Start pppoe-server on the PC end and enter the following command:
sudo pppoe-server -I eth0
(2) pppoe-client
After porting the pppoe module to android, we can also use rp-pppoe. We can build the module and port it to the android terminal. We need to write make file by ourselves. Here we use Android. mk:
LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)LOCAL_SRC_FILES:=\ src/pppoe.c \ src/if.c \ src/debug.c \ src/common.c \ src/ppp.c \ src/discovery.cLOCAL_MODULE_PATH := $(LOCAL_PATH)LOCAL_MODULE_TAGS := optionalLOCAL_MODULE := pppoeLOCAL_C_INCLUDES += $(LOCAL_PATH)/srcinclude $(BUILD_EXECUTABLE)include $(call all-makefiles-under,$(LOCAL_PATH))
The pppoe executable module is built and pushed to/system/bin. Of course, you can directly rewrite the makefile of rp-pppoe. Therefore, you can initiate a pppoe connection request on the terminal.
(3) run the test
(1) first, ensure that both the Client and Server are in the same broadcast domain. According to the above idea, the handheld terminal is linked to the wireless router connected to the LAN through wifi, the PC is directly connected to the LAN.
(2) After adb enters the device terminal, enter
/system/bin/pppoe -d
Discorvery will be initiated to broadcast the PADI packet in the broadcast domain. If the packet is successful, the MAC address of the pppoe-server will be returned, and eth0 will be captured on the PC side, use ppp | pppoed for filtering to receive broadcast packets from the terminal. This shows that the pppoe path has been implemented. Next:
/system/bin/pppd pty "/system/bin/pppoe -I wlan0" user user_xiaokeweng password my_password
In this way, the pppoe link will be initiated. After Discovery, authentication, and LCP, the ppp link will be established. On the PC side, you will see the newly created ppp0 and on the Client side.
(4) Subsequent Configuration
(1) Configure iptable on the PC side so that the terminal data packets can request access to internets
Echo 1>/proc/sys/net/ipv4/ip_forward // open iptable, run iptables-t nat-F // to clear the table item iptables-t nat-L // The actual table item iptables-t nat-a postrouting-s 192.168.1.1-j SNAT -- to 192.168.163.254 //-s is the ip address obtained by the terminal, -- to is the ip address of ethx
(2) Add route table items on the terminal
Ip-d route // view route table entry ip route del default // delete all default, you need to perform operations multiple times on the ip route add default dev ppp0 // set the default route to ppp0ip-d route // view it again
(3) Configure dns
In this case, you do not need to set dns because the dns-server used when connecting to the wlan is exactly the same as the current one, if you can ping the internet but cannot access the internet, it must be a dns problem.
Getprop net. dns1 // view default route 1 getprop net. dns2 // view the default route 2 setprop net. dns1 110.112.120.115 // set the default route 1 setprop net. dns2 110.112.120.114 // set the default route 2