cnat: Destination based NAT
[vpp.git] / src / plugins / cnat / cnat.rst
1 .. _dev_cnat:
2
3 .. toctree::
4
5 Cloud NAT
6 =========
7
8 Overview
9 ________
10
11 This plugin covers specific NAT use-cases that come mostly
12 from the container networking world. On the contraty of the
13 NAT concepts used for e.g. a home gateway, there is no notion
14 of 'outside' and 'inside'. We handle Virtual (or Real) IPs and
15 translations of the packets destined to them
16
17 Terminology & Usage
18 ___________________
19
20 Setting up the NAT will consist in the creation of a translation
21 that has several backends. A translation is 3-tuple containing :
22 a fully qualified IP address a port and a protocol. All packets
23 destined to it (ip, port) will then choose one of the backends,
24 and follow its rewrite rules.
25
26 A backend consists of four rewrites components (source & destination
27 address, source & destination port) that shall be applied to packets
28 on the way in, and reverted on the way back.
29
30 Backends are equally load-balanced with a flow hash. The choice
31 of a backend for a flow will trigger the creation of a NAT session,
32 that will store the packet rewrite to do and the one to undo
33 until the flow is reset or a timeout is reached
34
35 Translating Addresses
36 ---------------------
37
38 In this example, all packets destined to 30.0.0.2:80 will be
39 rewritten so that their destination IP is 20.0.0.1 and destination
40 port 8080. Here 30.0.0.2 has to be a virtual IP, it cannot be
41 assigned to an interface
42
43 .. code-block:: console
44
45   cnat translation add proto TCP vip 30.0.0.2 80 to ->20.0.0.1 8080
46
47
48 If 30.0.0.2 is the address of an interface, we can use the following
49 to do the same translation, and additionnaly change the source.
50 address with 1.2.3.4
51
52 .. code-block:: console
53
54   cnat translation add proto TCP real 30.0.0.2 80 to 1.2.3.4->20.0.0.1 8080
55
56 To show existing translations and sessions you can use
57
58 .. code-block:: console
59
60   cnat show session verbose
61   cant show translation
62
63
64 SourceNATing outgoing traffic
65 -----------------------------
66
67 A independant part of the plugin allows changing the source address
68 of outgoing traffic on a per-interface basis.
69
70 .. code-block:: console
71
72   cnat snat with 30::1
73   cnat snat exclude 20::/100
74   ex_ctl _calico_master cnat snat exclude 10::/100
75   ex_ctl _calico_master set interface feature tap0 ip6-cnat-snat arc ip6-unicast
76
77
78
79 Extending the NAT
80 _________________
81