blob: fdcc052a4bca4de5f2c1a22c7c2439856316be12 [file] [log] [blame]
Phil Sutterec0bab12016-03-04 13:11:39 +01001.TH "NAT action in tc" 8 "12 Jan 2015" "iproute2" "Linux"
2
3.SH NAME
4nat - stateless native address translation action
5.SH SYNOPSIS
6.in +8
7.ti -8
8.BR tc " ... " "action nat"
9.I DIRECTION OLD NEW
10
11.ti -8
12.IR DIRECTION " := { "
13.BR ingress " | " egress " }"
14
15.ti -8
16.IR OLD " := " IPV4_ADDR_SPEC
17
18.ti -8
19.IR NEW " := " IPV4_ADDR_SPEC
20
21.ti -8
22.IR IPV4_ADDR_SPEC " := { "
23.BR default " | " any " | " all " | "
24\fIin_addr\fR[\fB/\fR{\fIprefix\fR|\fInetmask\fR}]
25.SH DESCRIPTION
26The
27.B nat
28action allows to perform NAT without the overhead of conntrack, which is
29desirable if the number of flows or addresses to perform NAT on is large. This
30action is best used in combination with the
31.B u32
32filter to allow for efficient lookups of a large number of stateless NAT rules
33in constant time.
34.SH OPTIONS
35.TP
36.B ingress
37Translate destination addresses, i.e. perform DNAT.
38.TP
39.B egress
40Translate source addresses, i.e. perform SNAT.
41.TP
42.I OLD
43Specifies addresses which should be translated.
44.TP
45.I NEW
46Specifies addresses which
47.I OLD
48should be translated into.
49.SH NOTES
50The accepted address format in
51.IR OLD " and " NEW
52is quite flexible. It may either consist of one of the keywords
53.BR default ", " any " or " all ,
54representing the all-zero IP address or a combination of IP address and netmask
55or prefix length separated by a slash
56.RB ( / )
57sign. In any case, the mask (or prefix length) value of
58.I OLD
59is used for
60.I NEW
61as well so that a one-to-one mapping of addresses is assured.
62
63Address translation is done using a combination of binary operations. First, the
64original (source or destination) address is matched against the value of
65.IR OLD .
66If the original address fits, the new address is created by taking the leading
67bits from
68.I NEW
69(defined by the netmask of
70.IR OLD )
71and taking the remaining bits from the original address.
72
73There is rudimental support for upper layer protocols, namely TCP, UDP and ICMP.
74While for the first two only checksum recalculation is performed, the action
75also takes care of embedded IP headers in ICMP packets by translating the
76respective address therein, too.
77.SH SEE ALSO
78.BR tc (8)