1 .\" Copyright (c) 2005 Gleb Smirnoff <glebius@FreeBSD.org>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .Nd NAT netgraph node type
38 node performs network address translation (NAT) of packets
44 engine for packet aliasing.
45 At this moment it supports the basic functionality of the library.
47 This node type has two hooks:
49 .Bl -tag -width foobar
51 Packets received on this hook are considered outgoing and would be
52 masqueraded to configured address.
54 Packets coming on this hook are considered incoming and would be
58 This node type supports the generic control messages, plus the following:
60 .It Dv NGM_NAT_SET_IPADDR Pq Li setaliasaddr
61 Configure aliasing address for node.
62 After both hooks are connected and aliasing address configured,
63 node is ready for aliasing operation.
66 This node shuts down upon receipt of a
68 control message, or when both hooks are disconnected.
70 In the following example packets are injected into
75 .Bd -literal -offset indent
77 ngctl mkpeer ipfw: nat 60 out
78 ngctl name ipfw:60 nat
79 ngctl connect ipfw: nat: 61 in
80 ngctl msg nat: setaliasaddr x.y.35.8
82 # Divert traffic into NAT node
83 ipfw add 300 netgraph 61 all from any to any in via fxp0
84 ipfw add 400 netgraph 60 all from any to any out via fxp0
86 # Let packets continue with after being (de)aliased
87 sysctl net.inet.ip.fw.one_pass=0
91 node can simply be inserted right after
94 In the following example we perform masquerading on a
95 serial line with HDLC encapsulation.
96 .Bd -literal -offset indent
97 /usr/sbin/ngctl -f- <<-SEQ
98 mkpeer cp0: cisco rawdata downstream
100 mkpeer hdlc: nat inet in
102 mkpeer nat: iface out inet
103 msg nat: setaliasaddr x.y.8.35
105 ifconfig ng0 x.y.8.35 x.y.8.1
115 node type was implemented in
118 .An Gleb Smirnoff Aq glebius@FreeBSD.org