Skip to main content

netns jail

Run a process in its own network jail. Provide some convenience functions for limited access.

This is unreviewed AI-generated code. However, I use it.

Motivation

I might be a bit oldschool, but I really dislike open sockets, unsecured sockets on localhost which allow privileged access to things. However, some services work like this and I am not about to go and match them all. The reason I describe this as oldskool is that you may choose to have one user per machine and use docker containerisation such that everyprocess having access to your localhost running all sorts of powerful things is not an issue.

This is a little jail which gives a process its own little network stack using linuxes netns containment. It can then optioally tunnel in secure connections using unix domain sockets.

Alterntives and prior work

You can do this yourself with netns or use something like docker for complete containerisation. For some use cases I explicitly want a shared filesystem for libraries and file access. There are likely other jail systems.

iptables has some crazy modules that allow you to limit port access to certain users but this rather crazy and hard to debug.

Installation

pipx install netns-jail

Usage

Run something listening on localhost inside the jail netns-jail --forward /tmp/test.sock:localhost:1024 -- nc -l 1024

Connect to it form outside using the socket. nc -U /tmp/test.sock

If you want to be able to connect to the internet and use dns use --nat and --dns respectively like so:

netns-jail --dns --nat curl https://www.google.com/

Metadata

Release files for netns-jail 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netns-jail 1.0.0
File Size Uploaded Provenance Actions
netns_jail-1.0.0.tar.gz 9.7 kB Without provenance Details for netns_jail-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for netns-jail 1.0.0
File Interpreter ABI Platform Actions
netns_jail-1.0.0-py3-none-any.whl Python 3 none any Details for netns_jail-1.0.0-py3-none-any.whl

Total release size: 18.9 kB

Release files / netns_jail-1.0.0.tar.gz

Download URL netns_jail-1.0.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3bf6ccb99e7d9c0dc66ada2a5990a66d20605ed01a3180e2fdb1883ce804e55c
BLAKE2b-256 checksum
How to use checksums
ed26a1396ec4a9e8783ba6c108a63a92f47d5119b21f0d4ac3dc46f9e875fea0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / netns_jail-1.0.0-py3-none-any.whl

Download URL netns_jail-1.0.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e14d8aa4ef594b197308015aa3eab32196c0c567da0bcc65d060e83e2889787b
BLAKE2b-256 checksum
How to use checksums
edca1a9dec1e9340d8fb71d216247bf7541927131e8501d3d480a29f38d90d50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for netns-jail 1.0.0

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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page