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.\" 2517a35ce7SGleb Smirnoff.\" $FreeBSD$ 2617a35ce7SGleb Smirnoff.\" 27b7841ae6SMaxim Sobolev.Dd December 12, 2018 2817a35ce7SGleb Smirnoff.Dt NG_NAT 4 2917a35ce7SGleb Smirnoff.Os 3017a35ce7SGleb Smirnoff.Sh NAME 3117a35ce7SGleb Smirnoff.Nm ng_nat 32a4be0b3cSRuslan Ermilov.Nd "NAT netgraph node type" 3317a35ce7SGleb Smirnoff.Sh SYNOPSIS 3417a35ce7SGleb Smirnoff.In netgraph/ng_nat.h 3517a35ce7SGleb Smirnoff.Sh DESCRIPTION 3617a35ce7SGleb SmirnoffAn 3717a35ce7SGleb Smirnoff.Nm 3817a35ce7SGleb Smirnoffnode performs network address translation (NAT) of packets 3917a35ce7SGleb Smirnoffpassing through it. 40a4be0b3cSRuslan ErmilovA 41a4be0b3cSRuslan Ermilov.Nm nat 4217a35ce7SGleb Smirnoffnode uses 4317a35ce7SGleb Smirnoff.Xr libalias 3 4417a35ce7SGleb Smirnoffengine for packet aliasing. 4517a35ce7SGleb Smirnoff.Sh HOOKS 4617a35ce7SGleb SmirnoffThis node type has two hooks: 47c60bda17SJoel Dahl.Bl -tag -width ".Va out" 48a4be0b3cSRuslan Ermilov.It Va out 49a4be0b3cSRuslan ErmilovPackets received on this hook are considered outgoing and will be 50a4be0b3cSRuslan Ermilovmasqueraded to a configured address. 51a4be0b3cSRuslan Ermilov.It Va in 52a4be0b3cSRuslan ErmilovPackets coming on this hook are considered incoming and will be 5317a35ce7SGleb Smirnoffdealiased. 5417a35ce7SGleb Smirnoff.El 5517a35ce7SGleb Smirnoff.Sh CONTROL MESSAGES 5617a35ce7SGleb SmirnoffThis node type supports the generic control messages, plus the following: 57c60bda17SJoel Dahl.Bl -tag -width foo 58c60bda17SJoel Dahl.It Dv NGM_NAT_SET_IPADDR Pq Ic setaliasaddr 59a4be0b3cSRuslan ErmilovConfigure aliasing address for a node. 60a4be0b3cSRuslan ErmilovAfter both hooks have been connected and aliasing address was configured, 61a4be0b3cSRuslan Ermilova node is ready for aliasing operation. 62c60bda17SJoel Dahl.It Dv NGM_NAT_SET_MODE Pq Ic setmode 63e842c540SAlexander MotinSet node's operation mode using supplied 64e842c540SAlexander Motin.Vt "struct ng_nat_mode" . 65e842c540SAlexander Motin.Bd -literal 66e842c540SAlexander Motinstruct ng_nat_mode { 67e842c540SAlexander Motin uint32_t flags; 68e842c540SAlexander Motin uint32_t mask; 69e842c540SAlexander Motin}; 70e842c540SAlexander Motin/* Supported flags: */ 71e842c540SAlexander Motin#define NG_NAT_LOG 0x01 72e842c540SAlexander Motin#define NG_NAT_DENY_INCOMING 0x02 73e842c540SAlexander Motin#define NG_NAT_SAME_PORTS 0x04 74e842c540SAlexander Motin#define NG_NAT_UNREGISTERED_ONLY 0x10 75e842c540SAlexander Motin#define NG_NAT_RESET_ON_ADDR_CHANGE 0x20 76e842c540SAlexander Motin#define NG_NAT_PROXY_ONLY 0x40 77e842c540SAlexander Motin#define NG_NAT_REVERSE 0x80 78e842c540SAlexander Motin.Ed 79c60bda17SJoel Dahl.It Dv NGM_NAT_SET_TARGET Pq Ic settarget 80e842c540SAlexander MotinConfigure target address for a node. 81e842c540SAlexander MotinWhen an incoming packet not associated with any pre-existing aliasing 82e842c540SAlexander Motinlink arrives at the host machine, it will be sent to the specified address. 83c60bda17SJoel Dahl.It Dv NGM_NAT_REDIRECT_PORT Pq Ic redirectport 84fffba935SAlexander MotinRedirect incoming connections arriving to given port(s) to 85fffba935SAlexander Motinanother host and port(s). 86fffba935SAlexander MotinThe following 87fffba935SAlexander Motin.Vt "struct ng_nat_redirect_port" 88fffba935SAlexander Motinmust be supplied as argument. 89fffba935SAlexander Motin.Bd -literal 90fffba935SAlexander Motin#define NG_NAT_DESC_LENGTH 64 91fffba935SAlexander Motinstruct ng_nat_redirect_port { 92fffba935SAlexander Motin struct in_addr local_addr; 93fffba935SAlexander Motin struct in_addr alias_addr; 94fffba935SAlexander Motin struct in_addr remote_addr; 95fffba935SAlexander Motin uint16_t local_port; 96fffba935SAlexander Motin uint16_t alias_port; 97fffba935SAlexander Motin uint16_t remote_port; 98fffba935SAlexander Motin uint8_t proto; 99fffba935SAlexander Motin char description[NG_NAT_DESC_LENGTH]; 100fffba935SAlexander Motin}; 101fffba935SAlexander Motin.Ed 102fffba935SAlexander Motin.Pp 103fffba935SAlexander MotinRedirection is assigned an unique ID which is returned as 104fffba935SAlexander Motinresponse to this message, and 105fffba935SAlexander Motininformation about redirection added to 106fffba935SAlexander Motinlist of static redirects which later can be retrieved by 107fffba935SAlexander Motin.Dv NGM_NAT_LIST_REDIRECTS 108fffba935SAlexander Motinmessage. 109c60bda17SJoel Dahl.It Dv NGM_NAT_REDIRECT_ADDR Pq Ic redirectaddr 110fffba935SAlexander MotinRedirect traffic for public IP address to a machine on the 111fffba935SAlexander Motinlocal network. 112fffba935SAlexander MotinThis function is known as 113fffba935SAlexander Motin.Em static NAT . 114fffba935SAlexander MotinThe following 115fffba935SAlexander Motin.Vt "struct ng_nat_redirect_addr" 116fffba935SAlexander Motinmust be supplied as argument. 117fffba935SAlexander Motin.Bd -literal 118fffba935SAlexander Motinstruct ng_nat_redirect_addr { 119fffba935SAlexander Motin struct in_addr local_addr; 120fffba935SAlexander Motin struct in_addr alias_addr; 121fffba935SAlexander Motin char description[NG_NAT_DESC_LENGTH]; 122fffba935SAlexander Motin}; 123fffba935SAlexander Motin.Ed 124fffba935SAlexander Motin.Pp 125fffba935SAlexander MotinUnique ID for this redirection is returned as response to this message. 126c60bda17SJoel Dahl.It Dv NGM_NAT_REDIRECT_PROTO Pq Ic redirectproto 127fffba935SAlexander MotinRedirect incoming IP packets of protocol 128fffba935SAlexander Motin.Va proto 129fffba935SAlexander Motin(see 130fffba935SAlexander Motin.Xr protocols 5 ) 131fffba935SAlexander Motinto a machine on the local network. 132fffba935SAlexander MotinThe following 133fffba935SAlexander Motin.Vt "struct ng_nat_redirect_proto" 134fffba935SAlexander Motinmust be supplied as argument. 135fffba935SAlexander Motin.Bd -literal 136fffba935SAlexander Motinstruct ng_nat_redirect_proto { 137fffba935SAlexander Motin struct in_addr local_addr; 138fffba935SAlexander Motin struct in_addr alias_addr; 139fffba935SAlexander Motin struct in_addr remote_addr; 140fffba935SAlexander Motin uint8_t proto; 141fffba935SAlexander Motin char description[NG_NAT_DESC_LENGTH]; 142fffba935SAlexander Motin}; 143fffba935SAlexander Motin.Ed 144fffba935SAlexander Motin.Pp 145fffba935SAlexander MotinUnique ID for this redirection is returned as response to this message. 146c60bda17SJoel Dahl.It Dv NGM_NAT_REDIRECT_DYNAMIC Pq Ic redirectdynamic 147fffba935SAlexander MotinMark redirection with specified ID as dynamic, i.e., it will serve 148fffba935SAlexander Motinfor exactly one next connection and then will be automatically 149fffba935SAlexander Motindeleted from internal links table. 150fffba935SAlexander MotinOnly fully specified links can be made dynamic. 151fffba935SAlexander MotinThe redirection with this ID is also immediately deleted from 152fffba935SAlexander Motinuser-visible list of static redirects (available through 153fffba935SAlexander Motin.Dv NGM_NAT_LIST_REDIRECTS 154fffba935SAlexander Motinmessage). 155c60bda17SJoel Dahl.It Dv NGM_NAT_REDIRECT_DELETE Pq Ic redirectdelete 156fffba935SAlexander MotinDelete redirection with specified ID (currently active 157fffba935SAlexander Motinconnections are not affected). 158c60bda17SJoel Dahl.It Dv NGM_NAT_ADD_SERVER Pq Ic addserver 159fffba935SAlexander MotinAdd another server to a pool. 160fffba935SAlexander MotinThis is used to transparently offload network load on a single server 161fffba935SAlexander Motinand distribute the load across a pool of servers, also known as 162fffba935SAlexander Motin.Em LSNAT 163fffba935SAlexander Motin(RFC 2391). 164fffba935SAlexander MotinThe following 165fffba935SAlexander Motin.Vt "struct ng_nat_add_server" 166fffba935SAlexander Motinmust be supplied as argument. 167fffba935SAlexander Motin.Bd -literal 168fffba935SAlexander Motinstruct ng_nat_add_server { 169fffba935SAlexander Motin uint32_t id; 170fffba935SAlexander Motin struct in_addr addr; 171fffba935SAlexander Motin uint16_t port; 172fffba935SAlexander Motin}; 173fffba935SAlexander Motin.Ed 174fffba935SAlexander Motin.Pp 175fffba935SAlexander MotinFirst, the redirection is set up by 176fffba935SAlexander Motin.Dv NGM_NAT_REDIRECT_PORT 177fffba935SAlexander Motinor 178fffba935SAlexander Motin.Dv NGM_NAT_REDIRECT_ADDR . 179fffba935SAlexander MotinThen, ID of that redirection is used in multiple 180fffba935SAlexander Motin.Dv NGM_NAT_ADD_SERVER 181fffba935SAlexander Motinmessages to add necessary number of servers. 182fffba935SAlexander MotinFor redirections created by 183fffba935SAlexander Motin.Dv NGM_NAT_REDIRECT_ADDR , 184fffba935SAlexander Motinthe 185fffba935SAlexander Motin.Va port 186fffba935SAlexander Motinis ignored and could have any value. 187fffba935SAlexander MotinOriginal redirection's parameters 188fffba935SAlexander Motin.Va local_addr 189fffba935SAlexander Motinand 190fffba935SAlexander Motin.Va local_port 191fffba935SAlexander Motinare also ignored after 192fffba935SAlexander Motin.Dv NGM_NAT_ADD_SERVER 193fffba935SAlexander Motinwas used (they are effectively replaced by server pool). 194c60bda17SJoel Dahl.It Dv NGM_NAT_LIST_REDIRECTS Pq Ic listredirects 195fffba935SAlexander MotinReturn list of configured static redirects as 196fffba935SAlexander Motin.Vt "struct ng_nat_list_redirects" . 197fffba935SAlexander Motin.Bd -literal 198fffba935SAlexander Motinstruct ng_nat_listrdrs_entry { 199fffba935SAlexander Motin uint32_t id; /* Anything except zero */ 200fffba935SAlexander Motin struct in_addr local_addr; 201fffba935SAlexander Motin struct in_addr alias_addr; 202fffba935SAlexander Motin struct in_addr remote_addr; 203fffba935SAlexander Motin uint16_t local_port; 204fffba935SAlexander Motin uint16_t alias_port; 205fffba935SAlexander Motin uint16_t remote_port; 206fffba935SAlexander Motin uint16_t proto; /* Valid proto or NG_NAT_REDIRPROTO_ADDR */ 207fffba935SAlexander Motin uint16_t lsnat; /* LSNAT servers count */ 208fffba935SAlexander Motin char description[NG_NAT_DESC_LENGTH]; 209fffba935SAlexander Motin}; 210fffba935SAlexander Motinstruct ng_nat_list_redirects { 211fffba935SAlexander Motin uint32_t total_count; 212fffba935SAlexander Motin struct ng_nat_listrdrs_entry redirects[]; 213fffba935SAlexander Motin}; 214fffba935SAlexander Motin#define NG_NAT_REDIRPROTO_ADDR (IPPROTO_MAX + 3) 215fffba935SAlexander Motin.Ed 216fffba935SAlexander Motin.Pp 217fffba935SAlexander MotinEntries of the 218fffba935SAlexander Motin.Va redirects 219fffba935SAlexander Motinarray returned in the unified format for all redirect types. 220fffba935SAlexander MotinPorts are meaningful only if protocol is either TCP or UDP 221fffba935SAlexander Motinand 222fffba935SAlexander Motin.Em static NAT 223fffba935SAlexander Motinredirection (created by 224fffba935SAlexander Motin.Dv NGM_NAT_REDIRECT_ADDR ) 225fffba935SAlexander Motinis indicated by 226fffba935SAlexander Motin.Va proto 227fffba935SAlexander Motinset to 228fffba935SAlexander Motin.Dv NG_NAT_REDIRPROTO_ADDR . 229fffba935SAlexander MotinIf 230fffba935SAlexander Motin.Va lsnat 231fffba935SAlexander Motinservers counter is greater than zero, then 232fffba935SAlexander Motin.Va local_addr 233fffba935SAlexander Motinand 234fffba935SAlexander Motin.Va local_port 235fffba935SAlexander Motinare also meaningless. 236c60bda17SJoel Dahl.It Dv NGM_NAT_PROXY_RULE Pq Ic proxyrule 237fffba935SAlexander MotinSpecify a transparent proxying rule (string must be 238fffba935SAlexander Motinsupplied as argument). 239fffba935SAlexander MotinSee 240fffba935SAlexander Motin.Xr libalias 3 241fffba935SAlexander Motinfor details. 24221f97e93SGleb Smirnoff.It Dv NGM_NAT_LIBALIAS_INFO Pq Ic libaliasinfo 24321f97e93SGleb SmirnoffReturn internal statistics of 24421f97e93SGleb Smirnoff.Xr libalias 3 24521f97e93SGleb Smirnoffinstance as 24621f97e93SGleb Smirnoff.Vt "struct ng_nat_libalias_info" . 24721f97e93SGleb Smirnoff.Bd -literal 24821f97e93SGleb Smirnoffstruct ng_nat_libalias_info { 24921f97e93SGleb Smirnoff uint32_t icmpLinkCount; 25021f97e93SGleb Smirnoff uint32_t udpLinkCount; 25121f97e93SGleb Smirnoff uint32_t tcpLinkCount; 25221f97e93SGleb Smirnoff uint32_t sctpLinkCount; 25321f97e93SGleb Smirnoff uint32_t pptpLinkCount; 25421f97e93SGleb Smirnoff uint32_t protoLinkCount; 25521f97e93SGleb Smirnoff uint32_t fragmentIdLinkCount; 25621f97e93SGleb Smirnoff uint32_t fragmentPtrLinkCount; 25721f97e93SGleb Smirnoff uint32_t sockCount; 25821f97e93SGleb Smirnoff}; 25921f97e93SGleb Smirnoff.Ed 26021f97e93SGleb SmirnoffIn case of 26121f97e93SGleb Smirnoff.Nm 2627c64ddd5SWarren Blockfailed to retrieve a certain counter 26321f97e93SGleb Smirnofffrom its 26421f97e93SGleb Smirnoff.Xr libalias 26521f97e93SGleb Smirnoffinstance, the corresponding field is returned as 26621f97e93SGleb Smirnoff.Va UINT32_MAX . 267b7841ae6SMaxim Sobolev.It Dv NGM_NAT_SET_DLT Pq Ic setdlt 268b7841ae6SMaxim SobolevSets the data link type on the 269b7841ae6SMaxim Sobolev.Va in 270b7841ae6SMaxim Sobolevand 271b7841ae6SMaxim Sobolev.Va out 272b7841ae6SMaxim Sobolevhooks. 273b7841ae6SMaxim SobolevCurrently, supported types are 274b7841ae6SMaxim Sobolev.Cm DLT_RAW 275b7841ae6SMaxim Sobolev(raw IP datagrams , no offset applied, the default) and 276b7841ae6SMaxim Sobolev.Cm DLT_EN10MB 277b7841ae6SMaxim Sobolev(Ethernet). DLT_ definitions can be found in 278b7841ae6SMaxim Sobolev.In net/bpf.h . 279b7841ae6SMaxim SobolevIf you want to work on the 280b7841ae6SMaxim Sobolev.Xr ipfw 8 281b7841ae6SMaxim Sobolevlevel you must use no additional offset by specifying 282b7841ae6SMaxim Sobolev.Cm DLT_RAW . 283b7841ae6SMaxim SobolevIf, however, you attach 284b7841ae6SMaxim Sobolev.Nm 285b7841ae6SMaxim Sobolevto a network interface directly and 286b7841ae6SMaxim Sobolev.Cm EN10MB 287b7841ae6SMaxim Sobolevis specified, then the extra offset will be applied to take into account 288b7841ae6SMaxim Sobolevlink-level header. 289b7841ae6SMaxim SobolevIn this mode the 290b7841ae6SMaxim Sobolev.Nm 291b7841ae6SMaxim Sobolevwould also inspect appropriate type field in the Ethernet header and 292b7841ae6SMaxim Sobolevpass-through any datagrams that are not IP packets. 293b7841ae6SMaxim Sobolev.It Dv NGM_NAT_GET_DLT Pq Ic getdlt 294b7841ae6SMaxim SobolevThis control message returns the current data link type of the 295b7841ae6SMaxim Sobolev.Va in 296b7841ae6SMaxim Sobolevand 297b7841ae6SMaxim Sobolev.Va out 298b7841ae6SMaxim Sobolevhooks. 29917a35ce7SGleb Smirnoff.El 300fffba935SAlexander Motin.Pp 301fffba935SAlexander MotinIn all redirection messages 302fffba935SAlexander Motin.Va local_addr 303fffba935SAlexander Motinand 304fffba935SAlexander Motin.Va local_port 305fffba935SAlexander Motinmean address and port of target machine in the internal network, 306fffba935SAlexander Motinrespectively. 307fffba935SAlexander MotinIf 308fffba935SAlexander Motin.Va alias_addr 309fffba935SAlexander Motinis zero, then default aliasing address (set by 310fffba935SAlexander Motin.Dv NGM_NAT_SET_IPADDR ) 311fffba935SAlexander Motinis used. 312fffba935SAlexander MotinConnections can also be restricted to be accepted only 313fffba935SAlexander Motinfrom specific external machines by using non-zero 314fffba935SAlexander Motin.Va remote_addr 315fffba935SAlexander Motinand/or 316fffba935SAlexander Motin.Va remote_port . 317fffba935SAlexander MotinEach redirection assigned an ID which can be later used for 318fffba935SAlexander Motinredirection manipulation on individual basis (e.g., removal). 319fffba935SAlexander MotinThis ID guaranteed to be unique until the node shuts down 320fffba935SAlexander Motin(it will not be reused after deletion), and is returned to 321fffba935SAlexander Motinuser after making each new redirection or can be found in 322fffba935SAlexander Motinthe stored list of all redirections. 323fffba935SAlexander MotinThe 324fffba935SAlexander Motin.Va description 325fffba935SAlexander Motinpassed to and from node unchanged, together with ID providing 326fffba935SAlexander Motina way for several entities to concurrently manipulate 327fffba935SAlexander Motinredirections in automated way. 32817a35ce7SGleb Smirnoff.Sh SHUTDOWN 32917a35ce7SGleb SmirnoffThis node shuts down upon receipt of a 33017a35ce7SGleb Smirnoff.Dv NGM_SHUTDOWN 33117a35ce7SGleb Smirnoffcontrol message, or when both hooks are disconnected. 33217a35ce7SGleb Smirnoff.Sh EXAMPLES 333a4be0b3cSRuslan ErmilovIn the following example, the packets are injected into a 334a4be0b3cSRuslan Ermilov.Nm nat 335a4be0b3cSRuslan Ermilovnode using the 33617a35ce7SGleb Smirnoff.Xr ng_ipfw 4 33717a35ce7SGleb Smirnoffnode. 33817a35ce7SGleb Smirnoff.Bd -literal -offset indent 33917a35ce7SGleb Smirnoff# Create NAT node 34017a35ce7SGleb Smirnoffngctl mkpeer ipfw: nat 60 out 34117a35ce7SGleb Smirnoffngctl name ipfw:60 nat 34217a35ce7SGleb Smirnoffngctl connect ipfw: nat: 61 in 34317a35ce7SGleb Smirnoffngctl msg nat: setaliasaddr x.y.35.8 34417a35ce7SGleb Smirnoff 34517a35ce7SGleb Smirnoff# Divert traffic into NAT node 34617a35ce7SGleb Smirnoffipfw add 300 netgraph 61 all from any to any in via fxp0 34717a35ce7SGleb Smirnoffipfw add 400 netgraph 60 all from any to any out via fxp0 34817a35ce7SGleb Smirnoff 34917a35ce7SGleb Smirnoff# Let packets continue with after being (de)aliased 35017a35ce7SGleb Smirnoffsysctl net.inet.ip.fw.one_pass=0 35117a35ce7SGleb Smirnoff.Ed 35217a35ce7SGleb Smirnoff.Pp 353a4be0b3cSRuslan ErmilovThe 35417a35ce7SGleb Smirnoff.Nm 355a4be0b3cSRuslan Ermilovnode can be inserted right after the 356a4be0b3cSRuslan Ermilov.Xr ng_iface 4 357a4be0b3cSRuslan Ermilovnode in the graph. 358a4be0b3cSRuslan ErmilovIn the following example, we perform masquerading on a 35917a35ce7SGleb Smirnoffserial line with HDLC encapsulation. 36017a35ce7SGleb Smirnoff.Bd -literal -offset indent 36117a35ce7SGleb Smirnoff/usr/sbin/ngctl -f- <<-SEQ 36217a35ce7SGleb Smirnoff mkpeer cp0: cisco rawdata downstream 36317a35ce7SGleb Smirnoff name cp0:rawdata hdlc 36417a35ce7SGleb Smirnoff mkpeer hdlc: nat inet in 36517a35ce7SGleb Smirnoff name hdlc:inet nat 36617a35ce7SGleb Smirnoff mkpeer nat: iface out inet 36717a35ce7SGleb Smirnoff msg nat: setaliasaddr x.y.8.35 36817a35ce7SGleb SmirnoffSEQ 36917a35ce7SGleb Smirnoffifconfig ng0 x.y.8.35 x.y.8.1 37017a35ce7SGleb Smirnoff.Ed 371b7841ae6SMaxim Sobolev.Pp 372b7841ae6SMaxim SobolevThe 373b7841ae6SMaxim Sobolev.Nm 374b7841ae6SMaxim Sobolevnode can also be attached directly to the physical interface 375b7841ae6SMaxim Sobolevvia 376b7841ae6SMaxim Sobolev.Xr ng_ether 4 377b7841ae6SMaxim Sobolevnode in the graph. 378b7841ae6SMaxim SobolevIn the following example, we perform masquerading on a 379b7841ae6SMaxim SobolevEthernet interface connected to a public network. 380b7841ae6SMaxim Sobolev.Bd -literal -offset indent 381b7841ae6SMaxim Sobolevifconfig igb0 inet x.y.8.35 netmask 0xfffff000 382b7841ae6SMaxim Sobolevroute add default x.y.0.1 383b7841ae6SMaxim Sobolev/usr/sbin/ngctl -f- <<-SEQ 384b7841ae6SMaxim Sobolev mkpeer igb0: nat lower in 385b7841ae6SMaxim Sobolev name igb0:lower igb0_NAT 386b7841ae6SMaxim Sobolev connect igb0: igb0_NAT: upper out 387b7841ae6SMaxim Sobolev msg igb0_NAT: setdlt 1 388b7841ae6SMaxim Sobolev msg igb0_NAT: setaliasaddr x.y.8.35 389b7841ae6SMaxim SobolevSEQ 390*1adc28f5SChristian Brueffer.Ed 39117a35ce7SGleb Smirnoff.Sh SEE ALSO 39217a35ce7SGleb Smirnoff.Xr libalias 3 , 39317a35ce7SGleb Smirnoff.Xr ng_ipfw 4 , 394a4be0b3cSRuslan Ermilov.Xr natd 8 , 395b7841ae6SMaxim Sobolev.Xr ngctl 8 , 396b7841ae6SMaxim Sobolev.Xr ng_ether 8 39717a35ce7SGleb Smirnoff.Sh HISTORY 39817a35ce7SGleb SmirnoffThe 39917a35ce7SGleb Smirnoff.Nm 40017a35ce7SGleb Smirnoffnode type was implemented in 40117a35ce7SGleb Smirnoff.Fx 6.0 . 40217a35ce7SGleb Smirnoff.Sh AUTHORS 4036c899950SBaptiste Daroussin.An Gleb Smirnoff Aq Mt glebius@FreeBSD.org 404