Linux TUN/TAP wrapper for Python
pytun is a Python module which let you create TUN/TAP device very easily.
License: MIT (see LICENSE)
Installation and Dependencies
Install pytun with pip install python-pytun or download this archive, decompress it and execute python setup.py install. As pytun is a C module you will need a compiler (e.g GCC) and the Python development headers installed on your system (e.g on Debian-like distribution check that build-essential and python-dev are present). There are no dependencies other than the Python Standard Library.
Documentation
NOTE: On most distributions you will need to be root to create TUN/TAP devices.
To create a TUN device:
from pytun import TunTapDevice tun = TunTapDevice()
To create a TAP device:
from pytun import TunTapDevice, IFF_TAP tap = TunTapDevice(flags=IFF_TAP)
To create a TUN/TAP device with a custom name use the name keyword:
tun = TunTapDevice(name='mytun')
You can get/set some parameters of the device directly:
print tun.name tun.addr = '10.8.0.1' tun.dstaddr = '10.8.0.2' tun.netmask = '255.255.255.0' tun.mtu = 1500
If the device is a TAP you can also get/set its MAC address:
tap.hwaddr = '\x00\x11\x22\x33\x44\x55' print tap.hwaddr
To make the device persistent:
tun.persist(True)
To bring up the device:
tun.up()
To bring down the device:
tun.down()
To enable/disable the queue associated with the device (works only if it has been created with IFF_MULTI_QUEUE):
tun.mq_attach() # enable the queue tun.mq_attach(False) # disable the queue
To read/write to the device, use the methods read(size) and write(buf):
buf = tun.read(tun.mtu) tun.write(buf)
To close the device:
tun.close()
You can also use TunTapDevice objects with all functions that expect a fileno() method (e.g select())
Metadata
Release files for python-pytun 2.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 386.8 kB
Release files / python_pytun-2.4.2-cp315-cp315-musllinux_1_2_x86_64.whl
| Download URL | python_pytun-2.4.2-cp315-cp315-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 27.9 kB |
| Tags | CPython 3.15 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
cffcf0d5ff276454270f23667cfc9790623122cca1a861db9b005fdc40c5141a
|
|
BLAKE2b-256 checksum How to use checksums |
ec6ae02afb0aee0528e01d1352c26512ed83f0d9dbff82b4ac99e9d0bc1b07d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | python_pytun-2.4.2-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 28.5 kB |
| Tags | CPython 3.15 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
7cf522e76c5efbdaf441574b040588053ae024ddf0c558982dad6ffb4088270c
|
|
BLAKE2b-256 checksum How to use checksums |
5297495251041dc31be2ea64d0afd96b60579b055f8d88af84050094da9a1d5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp314-cp314-musllinux_1_2_x86_64.whl
| Download URL | python_pytun-2.4.2-cp314-cp314-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 27.7 kB |
| Tags | CPython 3.14 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
b3eb8f795b79b2c4131075badf79bd6de53e9ed1465b6580e128f3fffa3aca5e
|
|
BLAKE2b-256 checksum How to use checksums |
04314c3f446cf46db0e1c5a45f21443eab8c503693eb8ea63561fd1e8ba6da54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | python_pytun-2.4.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 28.1 kB |
| Tags | CPython 3.14 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
080fd6145d928f496831b7c8d4a27007c56058c66e4a9c0fcfc4ad4111cbac82
|
|
BLAKE2b-256 checksum How to use checksums |
a421e30d10798b6298f7e8507dc03cb94a9940bbd11cf0f4b3f537b947ff71bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp313-cp313-musllinux_1_2_x86_64.whl
| Download URL | python_pytun-2.4.2-cp313-cp313-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 27.6 kB |
| Tags | CPython 3.13 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
84e9c67b2a1f4af6d0de1cee4cee3ad3e00430e92e36963cccd355f3bd605d20
|
|
BLAKE2b-256 checksum How to use checksums |
f920ff8dcb6f56168d7a5ab636f170dc16acd9f62729b11a2fda187f9455c03b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | python_pytun-2.4.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 28.1 kB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
51f3c2446cda3ad4d9f588cceb3cf7eda607aefd6e357c522f424c81802c3049
|
|
BLAKE2b-256 checksum How to use checksums |
9fa573d4325fb8f193de420fb5986538ad19f92a5c2b74058ad359ab00442dd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp312-cp312-musllinux_1_2_x86_64.whl
| Download URL | python_pytun-2.4.2-cp312-cp312-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 27.6 kB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
2cc95c5a70f5f05b22ec51aeaa047bda1311dbac52a1216cbbd423d9bd9179ed
|
|
BLAKE2b-256 checksum How to use checksums |
7972dd5f7c7d6e833a0894b4c324c90410d4d847a9443796b45edea71e31d573
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | python_pytun-2.4.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 28.0 kB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
88cef64bbcb65503ddc80f0ca49c8df0a599d7fd3290e26cf3febf9697b66215
|
|
BLAKE2b-256 checksum How to use checksums |
f0fa21780a31bdccf043ec8f825029824336beb84e6287eb23d0e63b6e4162d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp311-cp311-musllinux_1_2_x86_64.whl
| Download URL | python_pytun-2.4.2-cp311-cp311-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 27.8 kB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
705fa357cdfc2d650510f66056e9b2cc76cf9fd681d2722d1551dad00d261c54
|
|
BLAKE2b-256 checksum How to use checksums |
fc8c1d0e4ac47bf089fc4ff8b14639dd16a3fe6d2858c92120735e170b1e20ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | python_pytun-2.4.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 28.2 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
ee50b84bbba65d426e786e8261d9629d1dc5caf61b39518e8bdacb69ef75b7bf
|
|
BLAKE2b-256 checksum How to use checksums |
d422b56cb247c607122aff9b6be182bde1e233e9372524c430d287a318735887
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp310-cp310-musllinux_1_2_x86_64.whl
| Download URL | python_pytun-2.4.2-cp310-cp310-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 26.9 kB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
312c528872b8334782c2aeab83b54a4de314fc614c8d7d0d7bcfb8f433199074
|
|
BLAKE2b-256 checksum How to use checksums |
89e340362d0c3595ba7d54623a7e3d7fb5305fcd3ff1511e3c76de701e159576
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | python_pytun-2.4.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 27.1 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
a09f92a2348cdf710bd6998922945661a6c2679e3c93423efbe34a97bfcd7d4b
|
|
BLAKE2b-256 checksum How to use checksums |
84a5523c59c2996118c79435e4108dc03bd51e19ec0aedb699973dc2f9d67290
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp39-cp39-musllinux_1_2_x86_64.whl
| Download URL | python_pytun-2.4.2-cp39-cp39-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 26.5 kB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
2fe956ead07988ca1dd5eaab8bcf2fbafd2058cefc5c0f0b501aa242c60e18c0
|
|
BLAKE2b-256 checksum How to use checksums |
5763b588e318888f0eca03499c97fbd5dab2915429ab69a58105e76281c48e50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / python_pytun-2.4.2-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | python_pytun-2.4.2-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 26.8 kB |
| Tags | CPython 3.9 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
593f1f01beee546fd6df7fe2ed660a31536ce9f9103d37bd4cd00c164cd483e9
|
|
BLAKE2b-256 checksum How to use checksums |
4e11c2ac82a1f63beb6f300cf2b366dea7820019ca0a4262f922d2bba67b5069
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for python-pytun 2.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.