|
Packit Service |
3880ab |
.TH "NAT action in tc" 8 "12 Jan 2015" "iproute2" "Linux"
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
.SH NAME
|
|
Packit Service |
3880ab |
nat - stateless native address translation action
|
|
Packit Service |
3880ab |
.SH SYNOPSIS
|
|
Packit Service |
3880ab |
.in +8
|
|
Packit Service |
3880ab |
.ti -8
|
|
Packit Service |
3880ab |
.BR tc " ... " "action nat"
|
|
Packit Service |
3880ab |
.I DIRECTION OLD NEW
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
.ti -8
|
|
Packit Service |
3880ab |
.IR DIRECTION " := { "
|
|
Packit Service |
3880ab |
.BR ingress " | " egress " }"
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
.ti -8
|
|
Packit Service |
3880ab |
.IR OLD " := " IPV4_ADDR_SPEC
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
.ti -8
|
|
Packit Service |
3880ab |
.IR NEW " := " IPV4_ADDR_SPEC
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
.ti -8
|
|
Packit Service |
3880ab |
.IR IPV4_ADDR_SPEC " := { "
|
|
Packit Service |
3880ab |
.BR default " | " any " | " all " | "
|
|
Packit Service |
3880ab |
\fIin_addr\fR[\fB/\fR{\fIprefix\fR|\fInetmask\fR}]
|
|
Packit Service |
3880ab |
.SH DESCRIPTION
|
|
Packit Service |
3880ab |
The
|
|
Packit Service |
3880ab |
.B nat
|
|
Packit Service |
3880ab |
action allows to perform NAT without the overhead of conntrack, which is
|
|
Packit Service |
3880ab |
desirable if the number of flows or addresses to perform NAT on is large. This
|
|
Packit Service |
3880ab |
action is best used in combination with the
|
|
Packit Service |
3880ab |
.B u32
|
|
Packit Service |
3880ab |
filter to allow for efficient lookups of a large number of stateless NAT rules
|
|
Packit Service |
3880ab |
in constant time.
|
|
Packit Service |
3880ab |
.SH OPTIONS
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.B ingress
|
|
Packit Service |
3880ab |
Translate destination addresses, i.e. perform DNAT.
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.B egress
|
|
Packit Service |
3880ab |
Translate source addresses, i.e. perform SNAT.
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.I OLD
|
|
Packit Service |
3880ab |
Specifies addresses which should be translated.
|
|
Packit Service |
3880ab |
.TP
|
|
Packit Service |
3880ab |
.I NEW
|
|
Packit Service |
3880ab |
Specifies addresses which
|
|
Packit Service |
3880ab |
.I OLD
|
|
Packit Service |
3880ab |
should be translated into.
|
|
Packit Service |
3880ab |
.SH NOTES
|
|
Packit Service |
3880ab |
The accepted address format in
|
|
Packit Service |
3880ab |
.IR OLD " and " NEW
|
|
Packit Service |
3880ab |
is quite flexible. It may either consist of one of the keywords
|
|
Packit Service |
3880ab |
.BR default ", " any " or " all ,
|
|
Packit Service |
3880ab |
representing the all-zero IP address or a combination of IP address and netmask
|
|
Packit Service |
3880ab |
or prefix length separated by a slash
|
|
Packit Service |
3880ab |
.RB ( / )
|
|
Packit Service |
3880ab |
sign. In any case, the mask (or prefix length) value of
|
|
Packit Service |
3880ab |
.I OLD
|
|
Packit Service |
3880ab |
is used for
|
|
Packit Service |
3880ab |
.I NEW
|
|
Packit Service |
3880ab |
as well so that a one-to-one mapping of addresses is assured.
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
Address translation is done using a combination of binary operations. First, the
|
|
Packit Service |
3880ab |
original (source or destination) address is matched against the value of
|
|
Packit Service |
3880ab |
.IR OLD .
|
|
Packit Service |
3880ab |
If the original address fits, the new address is created by taking the leading
|
|
Packit Service |
3880ab |
bits from
|
|
Packit Service |
3880ab |
.I NEW
|
|
Packit Service |
3880ab |
(defined by the netmask of
|
|
Packit Service |
3880ab |
.IR OLD )
|
|
Packit Service |
3880ab |
and taking the remaining bits from the original address.
|
|
Packit Service |
3880ab |
|
|
Packit Service |
3880ab |
There is rudimental support for upper layer protocols, namely TCP, UDP and ICMP.
|
|
Packit Service |
3880ab |
While for the first two only checksum recalculation is performed, the action
|
|
Packit Service |
3880ab |
also takes care of embedded IP headers in ICMP packets by translating the
|
|
Packit Service |
3880ab |
respective address therein, too.
|
|
Packit Service |
3880ab |
.SH SEE ALSO
|
|
Packit Service |
3880ab |
.BR tc (8)
|