{"id":15008866,"url":"https://github.com/montag451/pytun","last_synced_at":"2025-10-08T18:11:17.054Z","repository":{"id":53734358,"uuid":"3637038","full_name":"montag451/pytun","owner":"montag451","description":"Linux TUN/TAP wrapper for Python","archived":false,"fork":false,"pushed_at":"2025-02-28T15:07:28.000Z","size":37,"stargazers_count":175,"open_issues_count":3,"forks_count":34,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-12T04:49:46.504Z","etag":null,"topics":["c","networking","python2","python3","tunnel","tuntap"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/montag451.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-03-06T10:59:22.000Z","updated_at":"2025-05-07T16:37:24.000Z","dependencies_parsed_at":"2024-06-18T20:01:15.855Z","dependency_job_id":"f072cb0f-5eee-4077-adf8-4d6f52ea0399","html_url":"https://github.com/montag451/pytun","commit_stats":{"total_commits":40,"total_committers":6,"mean_commits":6.666666666666667,"dds":0.125,"last_synced_commit":"8e66674075d14643399d6e32d6657e5b8c1c63d2"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/montag451%2Fpytun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/montag451%2Fpytun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/montag451%2Fpytun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/montag451%2Fpytun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/montag451","download_url":"https://codeload.github.com/montag451/pytun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254346624,"owners_count":22055808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","networking","python2","python3","tunnel","tuntap"],"created_at":"2024-09-24T19:21:11.248Z","updated_at":"2025-10-08T18:11:12.027Z","avatar_url":"https://github.com/montag451.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Linux TUN/TAP wrapper for Python\n================================\n\n``pytun`` is a Python module which let you create TUN/TAP device very easily.\n\nLicense: MIT (see LICENSE)\n\nInstallation and Dependencies\n-----------------------------\n\nInstall ``pytun`` with ``pip install python-pytun`` or `download this archive\n\u003chttps://github.com/montag451/pytun/zipball/v2.3.0\u003e`_, decompress it and\nexecute ``python setup.py install``. As ``pytun`` is a C module you will need a\ncompiler (e.g GCC) and the Python development headers installed on your\nsystem (e.g on Debian-like distribution check that ``build-essential`` and\n``python-dev`` are present). There are no dependencies other than the Python\nStandard Library.\n\nDocumentation\n-------------\n\nNOTE: On most distributions you will need to be root to create TUN/TAP devices.\n\nTo create a TUN device::\n\n    from pytun import TunTapDevice\n\n    tun = TunTapDevice()\n\nTo create a TAP device::\n\n    from pytun import TunTapDevice, IFF_TAP\n\n    tap = TunTapDevice(flags=IFF_TAP)\n\nTo create a TUN/TAP device with a custom name use the ``name`` keyword::\n\n    tun = TunTapDevice(name='mytun')\n\nYou can get/set some parameters of the device directly::\n\n    print tun.name\n    tun.addr = '10.8.0.1'\n    tun.dstaddr = '10.8.0.2'\n    tun.netmask = '255.255.255.0'\n    tun.mtu = 1500\n\nIf the device is a TAP you can also get/set its MAC address::\n\n    tap.hwaddr = '\\x00\\x11\\x22\\x33\\x44\\x55'\n    print tap.hwaddr\n\nTo make the device persistent::\n\n    tun.persist(True)\n\nTo bring up the device::\n\n    tun.up()\n\nTo bring down the device::\n\n    tun.down()\n\nTo enable/disable the queue associated with the device (works only if\nit has been created with IFF_MULTI_QUEUE)::\n\n    tun.mq_attach() # enable the queue\n    tun.mq_attach(False) # disable the queue\n\nTo read/write to the device, use the methods ``read(size)`` and\n``write(buf)``::\n\n    buf = tun.read(tun.mtu)\n    tun.write(buf)\n\nTo close the device::\n\n    tun.close()\n\nYou can also use ``TunTapDevice`` objects with all functions that expect a\n``fileno()`` method (e.g ``select()``)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmontag451%2Fpytun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmontag451%2Fpytun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmontag451%2Fpytun/lists"}