Skip to content

vr_nat4

Michal Opala edited this page Feb 6, 2024 · 8 revisions

NAT4

Use this mode when the VMs behind the Virtual Router have private IP addresses, and your goal is to enable their internet access through the Virtual Router. This feature enables MASQUERADE in the POSTROUTING iptables chain.

The following figure depicts the basic LAN topology assumed by the module:

            public Network
      ┌───────────────────────
   ┌──┴─┐ (*) NAT
┌──┤eth0├──┐
│  └────┘  │
│  Virtual │
│  Router  │
│  ┌────┐  │
└──┤eth1├──┘
   └─┬──┘
     │   private network (e.g. 192.168.0.0/24)
     └────┬───────────┬────────────┬──────────
       ┌──┴──┐     ┌──┴──┐      ┌──┴──┐
       │ VM1 │     │ VM2 │      │ VM3 │
       └─────┘     └─────┘      └─────┘

Virtual Router Configuration

The following attributes control the basic configuration for NAT'ing:

  • ONEAPP_VNF_NAT4_ENABLED to activate the module
  • ONEAPP_VNF_NAT4_INTERFACES_OUT defines the public interface

For example, for the example above simply add:

CONTEXT = [
  ...
  ONEAPP_VNF_NAT4_ENABLED        = "YES",
  ONEAPP_VNF_NAT4_INTERFACES_OUT = "eth0",
  ...
]

Gives:

$ iptables -t nat -vnL NAT4
Chain NAT4 (1 references)
 pkts bytes target     prot opt in     out     source               destination
12345 6789K MASQUERADE  0    --  *      eth0    0.0.0.0/0            0.0.0.0/0

Context Configuration Attributes

Parameter Default Description
ONEAPP_VNF_NAT4_ENABLED NO Enable/Disable NAT feature (YES/NO)
ONEAPP_VNF_NAT4_INTERFACES_OUT no NICs Mandatory: Outgoing NICs for NAT (<[!]ethX> ...)
Clone this wiki locally