pytap3 - Cross-platform tunnel interface for Python
This is a cross-platform fork of the original johnthagen/pytap2. It provides a packet-oriented interface to TUN devices on Linux, macOS, and Windows.
For amateur radio operators, it also includes a handy command-line utility, kisstun, which automatically creates and configures a TUN interface from an IPv4 address and prefix, then bridges IP packets between that interface and a TCP-connected KISS TNC such as Dire Wolf. Instant, cross-platform packet radio networking!
Requirements
Requirements depend on your operating system:
Linux: Install net-tools to provide the ifconfig command.
On Debian/Ubuntu:
$ sudo apt install net-toolsOn RHEL/Rocky Linux/Fedora:
$ sudo yum install net-toolsmacOS: No additional packages are required; ifconfig is included with macOS.
Windows: wintun.dll is required. When building/installing from source on Windows, the package downloads the signed Wintun 0.14.1 archive from Wintun, verifies its SHA-256 checksum, and bundles the DLL matching the Python platform. This requires network access during installation. Wheels are platform-tagged; build Windows wheels on Windows to include the DLL. Source distributions build locally on any supported OS.
Creating and configuring a TUN device may require administrator or root privileges.
Installation
You can install, upgrade, and uninstall pytap3 with these commands:
$ pip install pytap3
$ pip install --upgrade pytap3
$ pip uninstall pytap3
Usage
Using as a context manager automatically brings up the device and closes it at the end of the with block.
from pytap3 import TapDevice
with TapDevice() as device:
device.ifconfig(mtu=1300)
device.write(b'0000')
Or manually call up() and close().
from pytap3 import TapDevice
device = TapDevice()
device.up()
device.ifconfig(mtu=1300)
device.write(b'0000')
device.close()
The fileno() method is defined, so that the device object can be passed directly to select(). This might not work on Windows, as the underlying Wintun driver does not support this.
On macOS, configuring an IP address with ifconfig(ip=..., netmask=...) also adds a route for that subnet through the utun interface. Routes that conflict with an existing route may require administrator privileges or manual adjustment.
- You can make pytap3 a drop-in replacement for pytap2 by just importing it like this:
import pytap3 as pytap2
kisstun command
Installing pytap3 provides the kisstun command. It creates and configures a TUN interface from an IPv4 address and prefix, then bridges IP packets between that interface and a TCP-connected KISS TNC. For example:
$ sudo kisstun 10.73.0.1/16
The default TCP KISS endpoint is 127.0.0.1:8001; the default KISS hardware port is 0 and MTU is 256. Use --host, --port, --kiss-port, and --mtu to change these settings. Run kisstun --help for the full option list. Creating the interface and routing its subnet may require root or administrator privileges.
To limit packet-radio traffic, kisstun filters outgoing packets by default, forwarding IPv4 unicast and broadcast only. It drops IPv6, IPv4 multicast, and UDP discovery traffic on ports 67, 68, 137, 138, 1900, 3702, 5353, and 5355 (DHCP, NetBIOS, SSDP, WS-Discovery, mDNS, and LLMNR), including broadcasts using those ports. Incoming KISS packets are passed to the TUN interface without this filter. Use --no-filter to disable filtering of outgoing packets.
Please note that TCP is a very chatty protocol and is not ideal for packet radio. Applications using UDP or ICMP are more suitable for this type of networking. If you are using TCP, consider tweaking the stack parameters to be more bandwidth-efficient, such as disabling Nagle’s algorithm and reducing the TCP window size.
The command can also be run as a Python module:
$ sudo python3 -m pytap3.kisstun 10.73.0.1/16
Pass --direwolf to launch direwolf from PATH and wait for its TCP KISS listener before connecting. Dire Wolf must be configured to listen at the selected endpoint (by default 127.0.0.1:8001). The child process is terminated when kisstun exits.
Specify a different TCP TNC endpoint, KISS port, or MTU with options:
$ sudo kisstun 10.73.0.1/16 --host 192.168.1.10 --port 8001 --kiss-port 2 --mtu 256
$ sudo kisstun 10.73.0.1/16 --direwolf
Releases
3.1.1 - 2026-10-27
Updated the kisstun outgoing packet filter to forward only the network broadcast.
3.1.0 - 2026-10-26
Added the kisstun utility for my fellow amateur radio operators.
3.0.2 - 2026-10-26
Bugfix: use interface routing on macOS, like the test was expecting.
3.0.0 - 2026-10-26
Windows, Linux and macOS support!
Metadata
Release files for pytap3 3.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytap3-3.1.1.tar.gz | 21.3 kB | Without provenance | Details for pytap3-3.1.1.tar.gz |
Release files / pytap3-3.1.1.tar.gz
| Download URL | pytap3-3.1.1.tar.gz |
|---|---|
| Size | 21.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b82261e77bdc6002c8919cd1846272df04c8909b51d92cfb9c462ea3fda2d553
|
|
BLAKE2b-256 checksum How to use checksums |
c222400a8a7b94e9fc07b333daf46f61e4152bf539b684429b8e493abd56439d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Security for pytap3 3.1.1
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.