NAT Management

Manage NAT pools and mappings

Rackd provides comprehensive NAT (Network Address Translation) mapping management for tracking external-to-internal IP/port translations.

Overview

NAT tracking allows you to document and manage NAT mappings in your network infrastructure. This is essential for:

  • Documenting firewall rules and port forwards
  • Tracking which external IPs map to internal services
  • Managing IP address utilization across NAT boundaries
  • Audit trail for NAT configuration changes

NAT Mapping Model

Each NAT mapping contains:

FieldTypeDescription
idstringUnique identifier (auto-generated UUID)
namestringDescriptive name for the mapping
external_ipstringExternal/public IP address
external_portintExternal port number (1-65535)
internal_ipstringInternal/private IP address
internal_portintInternal port number (1-65535)
protocolstringProtocol: tcp, udp, or any (default: tcp)
device_idstringOptional linked device ID
datacenter_idstringOptional datacenter ID
network_idstringOptional network ID
descriptionstringOptional description
enabledboolWhether the mapping is active (default: true)
tags[]stringOptional tags for categorization
created_attimestampCreation timestamp
updated_attimestampLast update timestamp

API Endpoints

List NAT Mappings

GET /api/nat

Query parameters:

  • protocol - Filter by protocol (tcp/udp/any)
  • external_ip - Filter by external IP address
  • internal_ip - Filter by internal IP address
  • device_id - Filter by device ID
  • datacenter_id - Filter by datacenter ID
  • enabled - Filter by enabled status (true/false)

Response:

[
  {
    "id": "nat-abc123",
    "name": "Web Server HTTPS",
    "external_ip": "203.0.113.10",
    "external_port": 443,
    "internal_ip": "192.168.1.10",
    "internal_port": 443,
    "protocol": "tcp",
    "enabled": true,
    "description": "HTTPS to internal web server",
    "tags": ["production", "web"]
  }
]

Get NAT Mapping

GET /api/nat/{id}

Create NAT Mapping

POST /api/nat

Request body:

{
  "name": "Web Server HTTPS",
  "external_ip": "203.0.113.10",
  "external_port": 443,
  "internal_ip": "192.168.1.10",
  "internal_port": 443,
  "protocol": "tcp",
  "description": "HTTPS to internal web server",
  "enabled": true,
  "tags": ["production", "web"]
}

Required fields: name, external_ip, external_port, internal_ip, internal_port

Update NAT Mapping

PUT /api/nat/{id}

All fields are optional for partial updates.

Delete NAT Mapping

DELETE /api/nat/{id}

CLI Commands

List NAT Mappings

# List all NAT mappings
rackd nat list

# Filter by protocol
rackd nat list --protocol tcp

# Filter by external IP
rackd nat list --external-ip 203.0.113.10

# Output as JSON
rackd nat list --output json

Get NAT Mapping

rackd nat get --id nat-abc123

Create NAT Mapping

rackd nat create \
  --name "Web Server HTTPS" \
  --external-ip 203.0.113.10 \
  --external-port 443 \
  --internal-ip 192.168.1.10 \
  --internal-port 443 \
  --protocol tcp \
  --description "HTTPS to internal web server" \
  --tags "production,web"

Update NAT Mapping

rackd nat update \
  --id nat-abc123 \
  --name "Updated Name" \
  --external-port 8443 \
  --disabled

Delete NAT Mapping

rackd nat delete --id nat-abc123

Web UI

Access NAT management at /nat in the web interface.

Features

  • List View: Table view with filtering by protocol, external IP, and enabled status
  • Create/Edit Modal: Form for creating and editing NAT mappings
  • Delete Confirmation: Confirmation dialog before deletion
  • Status Indicators: Visual indicators for enabled/disabled mappings
  • Tag Support: Add and manage tags for categorization

RBAC Permissions

NAT tracking uses the following permissions:

PermissionDescription
nat:listView list of NAT mappings
nat:readView individual NAT mapping details
nat:createCreate new NAT mappings
nat:updateModify existing NAT mappings
nat:deleteDelete NAT mappings

Default Role Assignments

  • admin: All NAT permissions
  • operator: All NAT permissions
  • viewer: nat:list, nat:read

Validation Rules

  1. Name: Required, cannot be empty
  2. External IP: Required, must be a valid IP address
  3. External Port: Required, must be 1-65535
  4. Internal IP: Required, must be a valid IP address
  5. Internal Port: Required, must be 1-65535
  6. Protocol: Must be one of tcp, udp, or any (defaults to tcp)

Use Cases

Port Forwarding Documentation

Document firewall port forwards for compliance and troubleshooting:

{
  "name": "Mail Server SMTP",
  "external_ip": "203.0.113.25",
  "external_port": 25,
  "internal_ip": "192.168.1.25",
  "internal_port": 25,
  "protocol": "tcp",
  "tags": ["email", "production"]
}

Load Balancer Backends

Track load balancer VIP to pool member mappings:

{
  "name": "Web Pool Member 1",
  "external_ip": "203.0.113.100",
  "external_port": 80,
  "internal_ip": "10.0.1.101",
  "internal_port": 8080,
  "protocol": "tcp"
}

Service Discovery Integration

Link NAT mappings to devices for automatic documentation:

{
  "name": "API Gateway",
  "external_ip": "203.0.113.50",
  "external_port": 443,
  "internal_ip": "10.0.2.50",
  "internal_port": 8443,
  "protocol": "tcp",
  "device_id": "dev-123"
}

Best Practices

  1. Naming Convention: Use descriptive names that include the service and environment
  2. Tagging: Use tags to group related mappings (e.g., by service, environment, customer)
  3. Device Linking: Link NAT mappings to devices when applicable for better visibility
  4. Documentation: Use the description field to document the purpose and any relevant ticket numbers
  5. Disabled State: Disable mappings instead of deleting them when decommissioning services (for audit trail)