Linux TUN/TAP wrapper for Python
Project description
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 developpement 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 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())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python-pytun-2.3.0.tar.gz.
File metadata
- Download URL: python-pytun-2.3.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ead86b3391acef239535ebcabeb04d2cdc6b40ab14580d28c6da193c2d1fe53
|
|
| MD5 |
adcaeea56d0ed06814487cdbde32d198
|
|
| BLAKE2b-256 |
52a4a062106c739eac79c8160fcf5779ebc84afc1c38b016ab216ed1e6da69b6
|
File details
Details for the file python_pytun-2.3.0-cp37-cp37m-manylinux1_x86_64.whl.
File metadata
- Download URL: python_pytun-2.3.0-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 31.0 kB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32be1cdf3c318b0ec88c64c90ae44ce041d8d98c1c8bb1b93646edefb0be8ef4
|
|
| MD5 |
f82a62623cec173d38600eea9ac8219a
|
|
| BLAKE2b-256 |
158a0331cec6ca6f434329767ab953a1044ccc829286932b4bed32762d52dab2
|
File details
Details for the file python_pytun-2.3.0-cp36-cp36m-manylinux1_x86_64.whl.
File metadata
- Download URL: python_pytun-2.3.0-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 30.0 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e5295767217f60e3fcbd2e73d4f8c798e9c5d9a09b3c6eedadaedfaf66c85d9
|
|
| MD5 |
af01117cb1af51639b914d04c855d871
|
|
| BLAKE2b-256 |
e44e9107c29d34f7c26053e68bda6e01faffe28e802d6d79a3bba1e70cba1df3
|
File details
Details for the file python_pytun-2.3.0-cp35-cp35m-manylinux1_x86_64.whl.
File metadata
- Download URL: python_pytun-2.3.0-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 29.9 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27aae68d347366058748a1d462fe817494863df65dca576a9fea4cf5c5cba884
|
|
| MD5 |
21f790859ff695bc7c6ab8ee1636cd33
|
|
| BLAKE2b-256 |
722b73bb31eec26f7e7f17388114f4bd230ce3797eb1ffe89009811f4625610e
|
File details
Details for the file python_pytun-2.3.0-cp34-cp34m-manylinux1_x86_64.whl.
File metadata
- Download URL: python_pytun-2.3.0-cp34-cp34m-manylinux1_x86_64.whl
- Upload date:
- Size: 29.7 kB
- Tags: CPython 3.4m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86a255c0233f2a2c30fade3d088e68dc5a70653e40824a286f23c3e61f978b7c
|
|
| MD5 |
1539fdeff1c260e4469ecf2bbcd73b2b
|
|
| BLAKE2b-256 |
f10bcccd65682da6b9a67a4abf4e5b0c29ae7f6b7667eceb641524334bf6309f
|
File details
Details for the file python_pytun-2.3.0-cp27-cp27mu-manylinux1_x86_64.whl.
File metadata
- Download URL: python_pytun-2.3.0-cp27-cp27mu-manylinux1_x86_64.whl
- Upload date:
- Size: 28.7 kB
- Tags: CPython 2.7mu
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5044add1b0b82bf68c47cb3f312edc243ed73b05cade5045758358148a529754
|
|
| MD5 |
4bb4ae0ec6b10e2e61e29490cbd09f1b
|
|
| BLAKE2b-256 |
8dc76ce9948c1473e29fcd10071e8a2b8626b7f33d7acbc161d6c6e036dc6348
|
File details
Details for the file python_pytun-2.3.0-cp27-cp27m-manylinux1_x86_64.whl.
File metadata
- Download URL: python_pytun-2.3.0-cp27-cp27m-manylinux1_x86_64.whl
- Upload date:
- Size: 28.7 kB
- Tags: CPython 2.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b918ff11b92f85781baffc258d6c94d49fb9367ad8c166724b88e46c46421f9
|
|
| MD5 |
48b01b652ed2261bc8fe323bf16e781a
|
|
| BLAKE2b-256 |
52dc534bf3d749abf2c9c5f40ba02721e37945651a504b8b8bfdf22a4723ec35
|