Skip to main content

Run a process in its own network namespace jail with optional unix socket forwarding and DNS tunneling

Project description

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/

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

netns_jail-1.0.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netns_jail-1.0.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file netns_jail-1.0.0.tar.gz.

File metadata

  • Download URL: netns_jail-1.0.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for netns_jail-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3bf6ccb99e7d9c0dc66ada2a5990a66d20605ed01a3180e2fdb1883ce804e55c
MD5 f35b95e3312d17d78a160a1b0c3d8e43
BLAKE2b-256 ed26a1396ec4a9e8783ba6c108a63a92f47d5119b21f0d4ac3dc46f9e875fea0

See more details on using hashes here.

File details

Details for the file netns_jail-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: netns_jail-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for netns_jail-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e14d8aa4ef594b197308015aa3eab32196c0c567da0bcc65d060e83e2889787b
MD5 0fd4455c4af4503bce70b7c6c8758625
BLAKE2b-256 edca1a9dec1e9340d8fb71d216247bf7541927131e8501d3d480a29f38d90d50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page