Skip to main content

NAT Configurator

NAT Configurator is a CLI tool designed to set up a Linux machine as a network gateway or router. By providing Network Address Translation (NAT) services to another network interface, the Linux machine can enable internet access for devices connected to this interface, effectively creating a network behind a gateway.

This is useful for scenarios where you have a set of devices connected to a local network and you want to manage their internet access through a single point. For instance, it can be used in a home network setup where the Linux machine is a central router connecting multiple devices to the internet.

Installation

This package is published on PyPI. You can install it using pip:

pip install nat-configurator

Alternatively, you can clone the repository and use poetry to build and install the package:

git clone https://github.com/your-github-username/nat-configurator.git
cd nat-configurator
poetry build
pip install dist/nat_configurator-0.1.0-py3-none-any.whl  # replace with actual filename

Note: You might need to run it with sudo if you encounter permission errors. This setup process involves configuring the network interface, dnsmasq, and firewall settings. Ensure to backup any existing configurations as this tool will overwrite them.

Usage

You can provide the required information as command line arguments:

sudo nat-configurator --ip <ip> --netmask <netmask> --dhcp-start-ip <start_ip> --dhcp-ip-count <ip_count> --wlan <wlan_interface> --lan <lan_interface>
  • --ip: The IP address to use for the NAT gateway.
  • --netmask: The netmask for the network.
  • --dhcp-start-ip: The start IP of the DHCP range.
  • --dhcp-ip-count: The number of IPs in the DHCP range.
  • --wlan: The incoming network interface (e.g., your WiFi interface).
  • --lan: The local network interface (e.g., your Ethernet interface).

If arguments are not provided via command line, the tool will prompt the user to enter the required information interactively.

sudo nat-configurator

The tool also checks for and installs necessary dependencies, checks the firewall conditions, enables IP forwarding, configures the network interface, and sets up DNSMasq and firewall.

Security Considerations

While setting up a Linux machine as a network gateway or router using NAT is a common practice and can simplify network management, it also comes with its own set of security implications that you need to consider. Here are a few:

  1. Single Point of Failure: The Linux machine acting as the NAT gateway becomes a single point of failure in your network setup. If it goes down or gets compromised, all devices using it for internet access may lose connectivity or risk exposure to threats.

  2. Internal Threats: If a device on the local network behind the NAT gateway is compromised, it can pose a threat to other devices on the same network. Since these devices are typically trusted, the compromised device could potentially launch attacks on other local devices or on the gateway itself.

  3. Security of the NAT Gateway: The security of your NAT gateway is paramount. Ensure it is well-protected against external threats. Keep the system updated, use strong passwords, limit SSH access, and implement necessary firewall rules.

  4. Limited Isolation: While NAT does provide a certain level of isolation between the local network and the internet, it should not be solely relied upon for security. Consider employing additional security measures such as firewalls, IDS/IPS, and regular system audits.

  5. Egress Filtering: NAT allows outbound connections from devices on the local network. If one of these devices becomes infected with malware, it could potentially use the NAT gateway to communicate with an external command and control server. Implementing egress filtering rules on the NAT gateway can help mitigate this risk.

This tool is designed to facilitate setting up a NAT gateway, but it's crucial to remember that security is an ongoing process. Always follow the best security practices and keep your systems updated.

Release files for nat-gateway-setup 0.11.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 nat-gateway-setup 0.11.0
File Size Uploaded
nat_gateway_setup-0.11.0.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nat-gateway-setup 0.11.0
File Interpreter ABI Platform
nat_gateway_setup-0.11.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.6 kB

Release files / nat_gateway_setup-0.11.0.tar.gz

Download URL nat_gateway_setup-0.11.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d6896fd4ac1823f1480f7bda8d7beed03784c9d989974037c3e6ff9724cfbf3c
BLAKE2b-256 checksum
How to use checksums
6e1ce3d2b112166a5402eef18303bfff8acf82422dba3791add1328a6b00862c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure

Release files / nat_gateway_setup-0.11.0-py3-none-any.whl

Download URL nat_gateway_setup-0.11.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9baec36d90f88260fe2b04d6db56743612b73cae1e9632ada9c9e304938ee9b2
BLAKE2b-256 checksum
How to use checksums
adcec78156ea635095b0086110cb7f35ecb2bfd3835df04950623ae85e9e3cf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure

Release history Release notifications | RSS feed

This release

0.11.0 This release

2 release files

0.6.0

2 release files

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