I am trying to connect a new PPoE session, send and receive some data and close the session.

I there a FOSS Python module to help me?

Note that I have found https://github.com/jamiesun/pyras but it does not seem to have any documentation :-(

[Update] I also found win32ras (at least, I found the documentation; I didn't yet find a download link), which seems useful, although not greatly documented. There are a few examples around.

What I am looking for here is an authoritative answer, from someone who has experience.

I require that the recommended Python module can perform full PPPoE, including LCP configuration and PADI/PDO, etc authentication (I strongly suspect that this is handled by Windows RAS service, but require confirmation).

The recommended documentation should also have adequate documentation or code examples to show how a URL can be sent and data received over the PPPoE connection which it establishes.

Linux support is a bonus, but not a "must have".

2 Answers 2


not good at English. you can import module win32ras

just like this : import win32ras

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" By the way,the module pyras is just a test,the author said: "本着学习的目的试了试,用python实现了一个pppoe拨号客户端,实现了基本的拨号和代理检测功能(采用了 shell xu的建议),放了一个简单的开源版,界面用的Tkinter,才200多行代码。

目前在win7 64下测试OK,xp还没有测试,问题应该不大。






[Update by OP] I ran that through Google translate and got

The purpose of learning to try the experiment, using python to achieve a pppoe dial-up client to achieve the basic dial-up and proxy detection (using the shell xu recommendations), put a simple open-source version of the interface with Tkinter , Only more than 200 lines of code.

Currently in the win7 64 test OK, xp has not been tested, the problem should not be.

And did not achieve PPPOE agreement, because I found that in fact can be a good use pywin32 system pppoe function. Each broadband connection has a rasphone.pbk configuration file, as long as a copy of the configuration will not be transferred to the system dialog box to create the process, many parameters can be configured. Use w32ras basic can be very good control.

The other is to use pycap and dpkt packet analysis and detection package agent found ip for the purpose of the machine's http request to determine the agent (does not affect the machine to access their http service)

I also want to prevent the routing function well, and AAA server expansion, the daily use of a dynamic user name, with the routing certainly tired of the.

Use pyinstaller package exe, most people decompile is not easy.


Answer from the OP, just in case it helps anyone in future

I simulated opening Control panel/Network connections and creating a new PPPoeE connection, then simulated clicking on the icon.


Search for the appropriate path (Windows moves it around in different versions, but it is always a .pbk file).

Write some Python code to create a similar file. here are the parts which I changed

with open(rasPhoneBookPath, "wt") as phoneBookFile :
    phoneBookFile.write('[' + pppoeSessionName + '\n')
    phoneBookFile.write("PhoneNumber=ACGC:AT+CGDCONT=' + bearerId + ',"IP","' + pppoeSessionName + '"\n")

and simulate a click to the icon by

rasDialResult = os.system("rasdial " + "' + pppoeSessionName + '" + " /PHONEBOOK:" + rasPhoneBookPath)

This works for me, on Windows 7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.