Skip to main content

Binds an IP-address to a subprocess through network namespaces - Linux only

Project description

Binds an IP-address to a subprocess through network namespaces - Linux only

Tested against Ubuntu / Python 3.11 + 3.10 / Anaconda

pip install pylinuxnetnamespace

Simplifies Network Namespace Management:

This library streamlines the process of creating and managing network namespaces and routing rules, reducing complexity and manual configuration efforts.

Effortless Command Execution:

With this library, executing commands within network namespaces becomes straightforward, allowing users to interact with isolated environments effortlessly.

Automation for Isolated Environments:

It provides a convenient way to automate the setup of isolated network environments, making it ideal for automating testing or development environments.

Streamlined Source NAT Configuration:

The library simplifies the configuration of Source NAT (SNAT) rules, a common requirement for network management.

Args:
	su_password (str): The superuser (sudo) password.
	networkip (str): The IP address to bind to the process.
	networkinterface (str, optional): The network interface to apply NAT rules to (default is 'eth0').
	nameserver (str, optional): The DNS nameserver IP address (default is '8.8.8.8').
	new_ip_start (str, optional): The starting IP address range for creating network interfaces (default is '192.168.').
	virtual_namespace_prefix (str, optional): The prefix for naming network namespaces (default is 'eth').

Returns:
	IpRun: An IpRun instance with the specified configuration.

Usage:
	# Create a bound subprocess that binds an IP address to a process using network namespaces.
	 from pylinuxnetnamespace import get_bound_subprocess_Popen
	bindedsubproc = get_bound_subprocess_Popen(su_password='1',
								   networkip='192.168.9.100',

								   networkinterface='enx344b50000000',
								   nameserver='8.8.8.8',
								   new_ip_start='192.168.',
								   virtual_namespace_prefix=f'eth')
	# bindedsubproc behaves like the subprocess.Popen class
	# you have to create it only once and can use it multiple times
	bindedsubproc('ping 1.1.1.1', shell=True)
	bindedsubproc('ping google.com', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

Project details


Release history Release notifications | RSS feed

This version

0.10

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylinuxnetnamespace-0.10.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

pylinuxnetnamespace-0.10-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file pylinuxnetnamespace-0.10.tar.gz.

File metadata

  • Download URL: pylinuxnetnamespace-0.10.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pylinuxnetnamespace-0.10.tar.gz
Algorithm Hash digest
SHA256 585e96408ba00a7339ecee8f06f14346ab79738ace1f6d6aa161cd0b7f197099
MD5 819e32af7eceb16def77bc55aed5c54f
BLAKE2b-256 93fe90af5e203606707b541c15e36b9a08b7be159ed537cc8b9323812c6bc0b0

See more details on using hashes here.

File details

Details for the file pylinuxnetnamespace-0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for pylinuxnetnamespace-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 5a266817a572e54fae2282fedc6b45fca73f6fa1fdb3a6156df87bcd551aa70a
MD5 15ce002e7a728d1f571eac4e7b26401d
BLAKE2b-256 5ad07f283af3062bdff1bda2baf0ca6fc267d962e4fc2bef1ac6822cb7013b7a

See more details on using hashes here.

Supported by

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