117a35ce7SGleb Smirnoff.\" Copyright (c) 2005 Gleb Smirnoff <glebius@FreeBSD.org> 217a35ce7SGleb Smirnoff.\" All rights reserved. 317a35ce7SGleb Smirnoff.\" 417a35ce7SGleb Smirnoff.\" Redistribution and use in source and binary forms, with or without 517a35ce7SGleb Smirnoff.\" modification, are permitted provided that the following conditions 617a35ce7SGleb Smirnoff.\" are met: 717a35ce7SGleb Smirnoff.\" 1. Redistributions of source code must retain the above copyright 817a35ce7SGleb Smirnoff.\" notice, this list of conditions and the following disclaimer. 917a35ce7SGleb Smirnoff.\" 2. Redistributions in binary form must reproduce the above copyright 1017a35ce7SGleb Smirnoff.\" notice, this list of conditions and the following disclaimer in the 1117a35ce7SGleb Smirnoff.\" documentation and/or other materials provided with the distribution. 1217a35ce7SGleb Smirnoff.\" 1317a35ce7SGleb Smirnoff.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1417a35ce7SGleb Smirnoff.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1517a35ce7SGleb Smirnoff.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1617a35ce7SGleb Smirnoff.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1717a35ce7SGleb Smirnoff.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1817a35ce7SGleb Smirnoff.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1917a35ce7SGleb Smirnoff.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2017a35ce7SGleb Smirnoff.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2117a35ce7SGleb Smirnoff.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2217a35ce7SGleb Smirnoff.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2317a35ce7SGleb Smirnoff.\" SUCH DAMAGE. 2417a35ce7SGleb Smirnoff.\" 255fe433a6SNeel Chauhan.Dd January 24, 2021 2617a35ce7SGleb Smirnoff.Dt NG_NAT 4 2717a35ce7SGleb Smirnoff.Os 2817a35ce7SGleb Smirnoff.Sh NAME 2917a35ce7SGleb Smirnoff.Nm ng_nat 30a4be0b3cSRuslan Ermilov.Nd "NAT netgraph node type" 3117a35ce7SGleb Smirnoff.Sh SYNOPSIS 3217a35ce7SGleb Smirnoff.In netgraph/ng_nat.h 3317a35ce7SGleb Smirnoff.Sh DESCRIPTION 3417a35ce7SGleb SmirnoffAn 3517a35ce7SGleb Smirnoff.Nm 3666351f51SMark Johnstonnode performs network address translation (NAT) of IPv4 packets 3717a35ce7SGleb Smirnoffpassing through it. 38a4be0b3cSRuslan ErmilovA 39a4be0b3cSRuslan Ermilov.Nm nat 4017a35ce7SGleb Smirnoffnode uses 4117a35ce7SGleb Smirnoff.Xr libalias 3 4217a35ce7SGleb Smirnoffengine for packet aliasing. 4317a35ce7SGleb Smirnoff.Sh HOOKS 4417a35ce7SGleb SmirnoffThis node type has two hooks: 45c60bda17SJoel Dahl.Bl -tag -width ".Va out" 46a4be0b3cSRuslan Ermilov.It Va out 47a4be0b3cSRuslan ErmilovPackets received on this hook are considered outgoing and will be 48a4be0b3cSRuslan Ermilovmasqueraded to a configured address. 49a4be0b3cSRuslan Ermilov.It Va in 50a4be0b3cSRuslan ErmilovPackets coming on this hook are considered incoming and will be 5117a35ce7SGleb Smirnoffdealiased. 5217a35ce7SGleb Smirnoff.El 5317a35ce7SGleb Smirnoff.Sh CONTROL MESSAGES 5417a35ce7SGleb SmirnoffThis node type supports the generic control messages, plus the following: 55c60bda17SJoel Dahl.Bl -tag -width foo 56c60bda17SJoel Dahl.It Dv NGM_NAT_SET_IPADDR Pq Ic setaliasaddr 57a4be0b3cSRuslan ErmilovConfigure aliasing address for a node. 58a4be0b3cSRuslan ErmilovAfter both hooks have been connected and aliasing address was configured, 59a4be0b3cSRuslan Ermilova node is ready for aliasing operation. 60c60bda17SJoel Dahl.It Dv NGM_NAT_SET_MODE Pq Ic setmode 61e842c540SAlexander MotinSet node's operation mode using supplied 62e842c540SAlexander Motin.Vt "struct ng_nat_mode" . 63e842c540SAlexander Motin.Bd -literal 64e842c540SAlexander Motinstruct ng_nat_mode { 65e842c540SAlexander Motin uint32_t flags; 66e842c540SAlexander Motin uint32_t mask; 67e842c540SAlexander Motin}; 68e842c540SAlexander Motin/* Supported flags: */ 69e842c540SAlexander Motin#define NG_NAT_LOG 0x01 70e842c540SAlexander Motin#define NG_NAT_DENY_INCOMING 0x02 71e842c540SAlexander Motin#define NG_NAT_SAME_PORTS 0x04 72e842c540SAlexander Motin#define NG_NAT_UNREGISTERED_ONLY 0x10 73e842c540SAlexander Motin#define NG_NAT_RESET_ON_ADDR_CHANGE 0x20 74e842c540SAlexander Motin#define NG_NAT_PROXY_ONLY 0x40 75e842c540SAlexander Motin#define NG_NAT_REVERSE 0x80 765fe433a6SNeel Chauhan#define NG_NAT_UNREGISTERED_CGN 0x100 77e842c540SAlexander Motin.Ed 785fe433a6SNeel Chauhan.Pp 795fe433a6SNeel ChauhanThe corresponding libalias flags can be found by replacing the 805fe433a6SNeel Chauhan.Vt "NG_NAT" 815fe433a6SNeel Chauhanprefix with 825fe433a6SNeel Chauhan.Vt "PKT_ALIAS" . 83c60bda17SJoel Dahl.It Dv NGM_NAT_SET_TARGET Pq Ic settarget 84e842c540SAlexander MotinConfigure target address for a node. 85e842c540SAlexander MotinWhen an incoming packet not associated with any pre-existing aliasing 86e842c540SAlexander Motinlink arrives at the host machine, it will be sent to the specified address. 87c60bda17SJoel Dahl.It Dv NGM_NAT_REDIRECT_PORT Pq Ic redirectport 88fffba935SAlexander MotinRedirect incoming connections arriving to given port(s) to 89fffba935SAlexander Motinanother host and port(s). 90fffba935SAlexander MotinThe following 91fffba935SAlexander Motin.Vt "struct ng_nat_redirect_port" 92fffba935SAlexander Motinmust be supplied as argument. 93fffba935SAlexander Motin.Bd -literal 94fffba935SAlexander Motin#define NG_NAT_DESC_LENGTH 64 95fffba935SAlexander Motinstruct ng_nat_redirect_port { 96fffba935SAlexander Motin struct in_addr local_addr; 97fffba935SAlexander Motin struct in_addr alias_addr; 98fffba935SAlexander Motin struct in_addr remote_addr; 99fffba935SAlexander Motin uint16_t local_port; 100fffba935SAlexander Motin uint16_t alias_port; 101fffba935SAlexander Motin uint16_t remote_port; 102fffba935SAlexander Motin uint8_t proto; 103fffba935SAlexander Motin char description[NG_NAT_DESC_LENGTH]; 104fffba935SAlexander Motin}; 105fffba935SAlexander Motin.Ed 106fffba935SAlexander Motin.Pp 107fffba935SAlexander MotinRedirection is assigned an unique ID which is returned as 108fffba935SAlexander Motinresponse to this message, and 109fffba935SAlexander Motininformation about redirection added to 110fffba935SAlexander Motinlist of static redirects which later can be retrieved by 111fffba935SAlexander Motin.Dv NGM_NAT_LIST_REDIRECTS 112fffba935SAlexander Motinmessage. 113c60bda17SJoel Dahl.It Dv NGM_NAT_REDIRECT_ADDR Pq Ic redirectaddr 114fffba935SAlexander MotinRedirect traffic for public IP address to a machine on the 115fffba935SAlexander Motinlocal network. 116fffba935SAlexander MotinThis function is known as 117fffba935SAlexander Motin.Em static NAT . 118fffba935SAlexander MotinThe following 119fffba935SAlexander Motin.Vt "struct ng_nat_redirect_addr" 120fffba935SAlexander Motinmust be supplied as argument. 121fffba935SAlexander Motin.Bd -literal 122fffba935SAlexander Motinstruct ng_nat_redirect_addr { 123fffba935SAlexander Motin struct in_addr local_addr; 124fffba935SAlexander Motin struct in_addr alias_addr; 125fffba935SAlexander Motin char description[NG_NAT_DESC_LENGTH]; 126fffba935SAlexander Motin}; 127fffba935SAlexander Motin.Ed 128fffba935SAlexander Motin.Pp 129fffba935SAlexander MotinUnique ID for this redirection is returned as response to this message. 130c60bda17SJoel Dahl.It Dv NGM_NAT_REDIRECT_PROTO Pq Ic redirectproto 131fffba935SAlexander MotinRedirect incoming IP packets of protocol 132fffba935SAlexander Motin.Va proto 133fffba935SAlexander Motin(see 134fffba935SAlexander Motin.Xr protocols 5 ) 135fffba935SAlexander Motinto a machine on the local network. 136fffba935SAlexander MotinThe following 137fffba935SAlexander Motin.Vt "struct ng_nat_redirect_proto" 138fffba935SAlexander Motinmust be supplied as argument. 139fffba935SAlexander Motin.Bd -literal 140fffba935SAlexander Motinstruct ng_nat_redirect_proto { 141fffba935SAlexander Motin struct in_addr local_addr; 142fffba935SAlexander Motin struct in_addr alias_addr; 143fffba935SAlexander Motin struct in_addr remote_addr; 144fffba935SAlexander Motin uint8_t proto; 145fffba935SAlexander Motin char description[NG_NAT_DESC_LENGTH]; 146fffba935SAlexander Motin}; 147fffba935SAlexander Motin.Ed 148fffba935SAlexander Motin.Pp 149fffba935SAlexander MotinUnique ID for this redirection is returned as response to this message. 150c60bda17SJoel Dahl.It Dv NGM_NAT_REDIRECT_DYNAMIC Pq Ic redirectdynamic 151fffba935SAlexander MotinMark redirection with specified ID as dynamic, i.e., it will serve 152fffba935SAlexander Motinfor exactly one next connection and then will be automatically 153fffba935SAlexander Motindeleted from internal links table. 154fffba935SAlexander MotinOnly fully specified links can be made dynamic. 155fffba935SAlexander MotinThe redirection with this ID is also immediately deleted from 156fffba935SAlexander Motinuser-visible list of static redirects (available through 157fffba935SAlexander Motin.Dv NGM_NAT_LIST_REDIRECTS 158fffba935SAlexander Motinmessage). 159c60bda17SJoel Dahl.It Dv NGM_NAT_REDIRECT_DELETE Pq Ic redirectdelete 160fffba935SAlexander MotinDelete redirection with specified ID (currently active 161fffba935SAlexander Motinconnections are not affected). 162c60bda17SJoel Dahl.It Dv NGM_NAT_ADD_SERVER Pq Ic addserver 163fffba935SAlexander MotinAdd another server to a pool. 164fffba935SAlexander MotinThis is used to transparently offload network load on a single server 165fffba935SAlexander Motinand distribute the load across a pool of servers, also known as 166fffba935SAlexander Motin.Em LSNAT 167fffba935SAlexander Motin(RFC 2391). 168fffba935SAlexander MotinThe following 169fffba935SAlexander Motin.Vt "struct ng_nat_add_server" 170fffba935SAlexander Motinmust be supplied as argument. 171fffba935SAlexander Motin.Bd -literal 172fffba935SAlexander Motinstruct ng_nat_add_server { 173fffba935SAlexander Motin uint32_t id; 174fffba935SAlexander Motin struct in_addr addr; 175fffba935SAlexander Motin uint16_t port; 176fffba935SAlexander Motin}; 177fffba935SAlexander Motin.Ed 178fffba935SAlexander Motin.Pp 179fffba935SAlexander MotinFirst, the redirection is set up by 180fffba935SAlexander Motin.Dv NGM_NAT_REDIRECT_PORT 181fffba935SAlexander Motinor 182fffba935SAlexander Motin.Dv NGM_NAT_REDIRECT_ADDR . 183fffba935SAlexander MotinThen, ID of that redirection is used in multiple 184fffba935SAlexander Motin.Dv NGM_NAT_ADD_SERVER 185fffba935SAlexander Motinmessages to add necessary number of servers. 186fffba935SAlexander MotinFor redirections created by 187fffba935SAlexander Motin.Dv NGM_NAT_REDIRECT_ADDR , 188fffba935SAlexander Motinthe 189fffba935SAlexander Motin.Va port 190fffba935SAlexander Motinis ignored and could have any value. 191fffba935SAlexander MotinOriginal redirection's parameters 192fffba935SAlexander Motin.Va local_addr 193fffba935SAlexander Motinand 194fffba935SAlexander Motin.Va local_port 195fffba935SAlexander Motinare also ignored after 196fffba935SAlexander Motin.Dv NGM_NAT_ADD_SERVER 197fffba935SAlexander Motinwas used (they are effectively replaced by server pool). 198c60bda17SJoel Dahl.It Dv NGM_NAT_LIST_REDIRECTS Pq Ic listredirects 199fffba935SAlexander MotinReturn list of configured static redirects as 200fffba935SAlexander Motin.Vt "struct ng_nat_list_redirects" . 201fffba935SAlexander Motin.Bd -literal 202fffba935SAlexander Motinstruct ng_nat_listrdrs_entry { 203fffba935SAlexander Motin uint32_t id; /* Anything except zero */ 204fffba935SAlexander Motin struct in_addr local_addr; 205fffba935SAlexander Motin struct in_addr alias_addr; 206fffba935SAlexander Motin struct in_addr remote_addr; 207fffba935SAlexander Motin uint16_t local_port; 208fffba935SAlexander Motin uint16_t alias_port; 209fffba935SAlexander Motin uint16_t remote_port; 210fffba935SAlexander Motin uint16_t proto; /* Valid proto or NG_NAT_REDIRPROTO_ADDR */ 211fffba935SAlexander Motin uint16_t lsnat; /* LSNAT servers count */ 212fffba935SAlexander Motin char description[NG_NAT_DESC_LENGTH]; 213fffba935SAlexander Motin}; 214fffba935SAlexander Motinstruct ng_nat_list_redirects { 215fffba935SAlexander Motin uint32_t total_count; 216fffba935SAlexander Motin struct ng_nat_listrdrs_entry redirects[]; 217fffba935SAlexander Motin}; 218fffba935SAlexander Motin#define NG_NAT_REDIRPROTO_ADDR (IPPROTO_MAX + 3) 219fffba935SAlexander Motin.Ed 220fffba935SAlexander Motin.Pp 221fffba935SAlexander MotinEntries of the 222fffba935SAlexander Motin.Va redirects 223fffba935SAlexander Motinarray returned in the unified format for all redirect types. 224fffba935SAlexander MotinPorts are meaningful only if protocol is either TCP or UDP 225fffba935SAlexander Motinand 226fffba935SAlexander Motin.Em static NAT 227fffba935SAlexander Motinredirection (created by 228fffba935SAlexander Motin.Dv NGM_NAT_REDIRECT_ADDR ) 229fffba935SAlexander Motinis indicated by 230fffba935SAlexander Motin.Va proto 231fffba935SAlexander Motinset to 232fffba935SAlexander Motin.Dv NG_NAT_REDIRPROTO_ADDR . 233fffba935SAlexander MotinIf 234fffba935SAlexander Motin.Va lsnat 235fffba935SAlexander Motinservers counter is greater than zero, then 236fffba935SAlexander Motin.Va local_addr 237fffba935SAlexander Motinand 238fffba935SAlexander Motin.Va local_port 239fffba935SAlexander Motinare also meaningless. 240c60bda17SJoel Dahl.It Dv NGM_NAT_PROXY_RULE Pq Ic proxyrule 241fffba935SAlexander MotinSpecify a transparent proxying rule (string must be 242fffba935SAlexander Motinsupplied as argument). 243fffba935SAlexander MotinSee 244fffba935SAlexander Motin.Xr libalias 3 245fffba935SAlexander Motinfor details. 24621f97e93SGleb Smirnoff.It Dv NGM_NAT_LIBALIAS_INFO Pq Ic libaliasinfo 24721f97e93SGleb SmirnoffReturn internal statistics of 24821f97e93SGleb Smirnoff.Xr libalias 3 24921f97e93SGleb Smirnoffinstance as 25021f97e93SGleb Smirnoff.Vt "struct ng_nat_libalias_info" . 25121f97e93SGleb Smirnoff.Bd -literal 25221f97e93SGleb Smirnoffstruct ng_nat_libalias_info { 25321f97e93SGleb Smirnoff uint32_t icmpLinkCount; 25421f97e93SGleb Smirnoff uint32_t udpLinkCount; 25521f97e93SGleb Smirnoff uint32_t tcpLinkCount; 25621f97e93SGleb Smirnoff uint32_t sctpLinkCount; 25721f97e93SGleb Smirnoff uint32_t pptpLinkCount; 25821f97e93SGleb Smirnoff uint32_t protoLinkCount; 25921f97e93SGleb Smirnoff uint32_t fragmentIdLinkCount; 26021f97e93SGleb Smirnoff uint32_t fragmentPtrLinkCount; 26121f97e93SGleb Smirnoff uint32_t sockCount; 26221f97e93SGleb Smirnoff}; 26321f97e93SGleb Smirnoff.Ed 26421f97e93SGleb SmirnoffIn case of 26521f97e93SGleb Smirnoff.Nm 2667c64ddd5SWarren Blockfailed to retrieve a certain counter 26721f97e93SGleb Smirnofffrom its 268*a51584a2SGraham Percival.Xr libalias 3 26921f97e93SGleb Smirnoffinstance, the corresponding field is returned as 27021f97e93SGleb Smirnoff.Va UINT32_MAX . 271b7841ae6SMaxim Sobolev.It Dv NGM_NAT_SET_DLT Pq Ic setdlt 272b7841ae6SMaxim SobolevSets the data link type on the 273b7841ae6SMaxim Sobolev.Va in 274b7841ae6SMaxim Sobolevand 275b7841ae6SMaxim Sobolev.Va out 276b7841ae6SMaxim Sobolevhooks. 277b7841ae6SMaxim SobolevCurrently, supported types are 278b7841ae6SMaxim Sobolev.Cm DLT_RAW 279b7841ae6SMaxim Sobolev(raw IP datagrams , no offset applied, the default) and 280b7841ae6SMaxim Sobolev.Cm DLT_EN10MB 281b7841ae6SMaxim Sobolev(Ethernet). DLT_ definitions can be found in 282b7841ae6SMaxim Sobolev.In net/bpf.h . 283b7841ae6SMaxim SobolevIf you want to work on the 284b7841ae6SMaxim Sobolev.Xr ipfw 8 285b7841ae6SMaxim Sobolevlevel you must use no additional offset by specifying 286b7841ae6SMaxim Sobolev.Cm DLT_RAW . 287b7841ae6SMaxim SobolevIf, however, you attach 288b7841ae6SMaxim Sobolev.Nm 289b7841ae6SMaxim Sobolevto a network interface directly and 290b7841ae6SMaxim Sobolev.Cm EN10MB 291b7841ae6SMaxim Sobolevis specified, then the extra offset will be applied to take into account 292b7841ae6SMaxim Sobolevlink-level header. 293b7841ae6SMaxim SobolevIn this mode the 294b7841ae6SMaxim Sobolev.Nm 295b7841ae6SMaxim Sobolevwould also inspect appropriate type field in the Ethernet header and 296b7841ae6SMaxim Sobolevpass-through any datagrams that are not IP packets. 297b7841ae6SMaxim Sobolev.It Dv NGM_NAT_GET_DLT Pq Ic getdlt 298b7841ae6SMaxim SobolevThis control message returns the current data link type of the 299b7841ae6SMaxim Sobolev.Va in 300b7841ae6SMaxim Sobolevand 301b7841ae6SMaxim Sobolev.Va out 302b7841ae6SMaxim Sobolevhooks. 30317a35ce7SGleb Smirnoff.El 304fffba935SAlexander Motin.Pp 305fffba935SAlexander MotinIn all redirection messages 306fffba935SAlexander Motin.Va local_addr 307fffba935SAlexander Motinand 308fffba935SAlexander Motin.Va local_port 309fffba935SAlexander Motinmean address and port of target machine in the internal network, 310fffba935SAlexander Motinrespectively. 311fffba935SAlexander MotinIf 312fffba935SAlexander Motin.Va alias_addr 313fffba935SAlexander Motinis zero, then default aliasing address (set by 314fffba935SAlexander Motin.Dv NGM_NAT_SET_IPADDR ) 315fffba935SAlexander Motinis used. 316fffba935SAlexander MotinConnections can also be restricted to be accepted only 317fffba935SAlexander Motinfrom specific external machines by using non-zero 318fffba935SAlexander Motin.Va remote_addr 319fffba935SAlexander Motinand/or 320fffba935SAlexander Motin.Va remote_port . 321fffba935SAlexander MotinEach redirection assigned an ID which can be later used for 322fffba935SAlexander Motinredirection manipulation on individual basis (e.g., removal). 323fffba935SAlexander MotinThis ID guaranteed to be unique until the node shuts down 324fffba935SAlexander Motin(it will not be reused after deletion), and is returned to 325fffba935SAlexander Motinuser after making each new redirection or can be found in 326fffba935SAlexander Motinthe stored list of all redirections. 327fffba935SAlexander MotinThe 328fffba935SAlexander Motin.Va description 329fffba935SAlexander Motinpassed to and from node unchanged, together with ID providing 330fffba935SAlexander Motina way for several entities to concurrently manipulate 331fffba935SAlexander Motinredirections in automated way. 33217a35ce7SGleb Smirnoff.Sh SHUTDOWN 33317a35ce7SGleb SmirnoffThis node shuts down upon receipt of a 33417a35ce7SGleb Smirnoff.Dv NGM_SHUTDOWN 33517a35ce7SGleb Smirnoffcontrol message, or when both hooks are disconnected. 33617a35ce7SGleb Smirnoff.Sh EXAMPLES 337a4be0b3cSRuslan ErmilovIn the following example, the packets are injected into a 338a4be0b3cSRuslan Ermilov.Nm nat 339a4be0b3cSRuslan Ermilovnode using the 34017a35ce7SGleb Smirnoff.Xr ng_ipfw 4 34117a35ce7SGleb Smirnoffnode. 34217a35ce7SGleb Smirnoff.Bd -literal -offset indent 34317a35ce7SGleb Smirnoff# Create NAT node 34417a35ce7SGleb Smirnoffngctl mkpeer ipfw: nat 60 out 34517a35ce7SGleb Smirnoffngctl name ipfw:60 nat 34617a35ce7SGleb Smirnoffngctl connect ipfw: nat: 61 in 34717a35ce7SGleb Smirnoffngctl msg nat: setaliasaddr x.y.35.8 34817a35ce7SGleb Smirnoff 34917a35ce7SGleb Smirnoff# Divert traffic into NAT node 35017a35ce7SGleb Smirnoffipfw add 300 netgraph 61 all from any to any in via fxp0 35117a35ce7SGleb Smirnoffipfw add 400 netgraph 60 all from any to any out via fxp0 35217a35ce7SGleb Smirnoff 35317a35ce7SGleb Smirnoff# Let packets continue with after being (de)aliased 35417a35ce7SGleb Smirnoffsysctl net.inet.ip.fw.one_pass=0 35517a35ce7SGleb Smirnoff.Ed 35617a35ce7SGleb Smirnoff.Pp 357a4be0b3cSRuslan ErmilovThe 35817a35ce7SGleb Smirnoff.Nm 359a4be0b3cSRuslan Ermilovnode can be inserted right after the 360a4be0b3cSRuslan Ermilov.Xr ng_iface 4 361a4be0b3cSRuslan Ermilovnode in the graph. 362a4be0b3cSRuslan ErmilovIn the following example, we perform masquerading on a 36317a35ce7SGleb Smirnoffserial line with HDLC encapsulation. 36417a35ce7SGleb Smirnoff.Bd -literal -offset indent 36517a35ce7SGleb Smirnoff/usr/sbin/ngctl -f- <<-SEQ 36617a35ce7SGleb Smirnoff mkpeer cp0: cisco rawdata downstream 36717a35ce7SGleb Smirnoff name cp0:rawdata hdlc 36817a35ce7SGleb Smirnoff mkpeer hdlc: nat inet in 36917a35ce7SGleb Smirnoff name hdlc:inet nat 37017a35ce7SGleb Smirnoff mkpeer nat: iface out inet 37117a35ce7SGleb Smirnoff msg nat: setaliasaddr x.y.8.35 37217a35ce7SGleb SmirnoffSEQ 37317a35ce7SGleb Smirnoffifconfig ng0 x.y.8.35 x.y.8.1 37417a35ce7SGleb Smirnoff.Ed 375b7841ae6SMaxim Sobolev.Pp 376b7841ae6SMaxim SobolevThe 377b7841ae6SMaxim Sobolev.Nm 378b7841ae6SMaxim Sobolevnode can also be attached directly to the physical interface 379b7841ae6SMaxim Sobolevvia 380b7841ae6SMaxim Sobolev.Xr ng_ether 4 381b7841ae6SMaxim Sobolevnode in the graph. 382b7841ae6SMaxim SobolevIn the following example, we perform masquerading on a 383b7841ae6SMaxim SobolevEthernet interface connected to a public network. 384b7841ae6SMaxim Sobolev.Bd -literal -offset indent 385b7841ae6SMaxim Sobolevifconfig igb0 inet x.y.8.35 netmask 0xfffff000 386b7841ae6SMaxim Sobolevroute add default x.y.0.1 387b7841ae6SMaxim Sobolev/usr/sbin/ngctl -f- <<-SEQ 388b7841ae6SMaxim Sobolev mkpeer igb0: nat lower in 389b7841ae6SMaxim Sobolev name igb0:lower igb0_NAT 390b7841ae6SMaxim Sobolev connect igb0: igb0_NAT: upper out 391b7841ae6SMaxim Sobolev msg igb0_NAT: setdlt 1 392b7841ae6SMaxim Sobolev msg igb0_NAT: setaliasaddr x.y.8.35 393b7841ae6SMaxim SobolevSEQ 3941adc28f5SChristian Brueffer.Ed 39517a35ce7SGleb Smirnoff.Sh SEE ALSO 39617a35ce7SGleb Smirnoff.Xr libalias 3 , 39717a35ce7SGleb Smirnoff.Xr ng_ipfw 4 , 398a4be0b3cSRuslan Ermilov.Xr natd 8 , 3996e1fc011SGraham Percival.Xr ng_ether 8 , 4006e1fc011SGraham Percival.Xr ngctl 8 40117a35ce7SGleb Smirnoff.Sh HISTORY 40217a35ce7SGleb SmirnoffThe 40317a35ce7SGleb Smirnoff.Nm 40417a35ce7SGleb Smirnoffnode type was implemented in 40517a35ce7SGleb Smirnoff.Fx 6.0 . 40617a35ce7SGleb Smirnoff.Sh AUTHORS 4076c899950SBaptiste Daroussin.An Gleb Smirnoff Aq Mt glebius@FreeBSD.org 408