huncrys/snat

By huncrys

Updated 3 months ago

Standalone version of netfilter-mailcow with SNAT support only

Image
Networking
0

5.2K

huncrys/snat repository overview

Docker SNAT

A minimal Docker container for managing SNAT (Source Network Address Translation) rules for both IPv4 and IPv6 using Python and python-iptables. Based on mailcow/netfilter.

Features

  • Automatically manages SNAT rules in the POSTROUTING chain for IPv4 and/or IPv6.
  • Ensures SNAT rules are present and in the correct order.
  • Cleans up SNAT rules on exit.

Source

Source code is hosted at https://oaklab.hu/crys/snat. Images are built by GitLab CI automatically.

Usage

Available tags
TagDescription
stableLatest stable version
latestLatest development version
X.Y.ZSpecific version (e.g., 3.0.0)
Environment Variables
VariableDescription
SNAT4_TO_SOURCEIPv4 address to use as the SNAT target
SNAT4_NETWORKIPv4 network (in CIDR notation) to match for SNAT
SNAT6_TO_SOURCEIPv6 address to use as the SNAT target
SNAT6_NETWORKIPv6 network (in CIDR notation) to match for SNAT
Example (Docker Compose)
services:
  snat:
    container_name: snat
    image: huncrys/snat
    environment:
      SNAT4_TO_SOURCE: "192.0.2.1"
      SNAT4_NETWORK: "192.0.2.0/24"
      SNAT6_TO_SOURCE: "2001:db8::1"
      SNAT6_NETWORK: "2001:db8::/64"
    network_mode: host
    cap_drop:
      - ALL
    cap_add:
      - NET_ADMIN
      - NET_RAW
      - SYS_MODULE
    volumes:
      - /lib/modules:/lib/modules:ro
    restart: unless-stopped
Example (Docker CLI)
docker run -d \
  --name snat \
  --net host \
  -e SNAT4_TO_SOURCE=192.0.2.1 \
  -e SNAT4_NETWORK=192.0.2.0/24 \
  -e SNAT6_TO_SOURCE=2001:db8::1 \
  -e SNAT6_NETWORK=2001:db8::/64 \
  --cap-drop ALL \
  --cap-add NET_ADMIN \
  --cap-add NET_RAW \
  --cap-add SYS_MODULE \
  -v /lib/modules:/lib/modules:ro \
  --restart unless-stopped \
  huncrys/snat

Tag summary

Content type

Image

Digest

sha256:853b78970

Size

18.6 MB

Last updated

3 months ago

docker pull huncrys/snat:36d8e0c1