1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
2000-06-27 11:39:36 +00:00
|
|
|
.Dd June 27, 2000
|
1997-06-22 04:19:08 +00:00
|
|
|
.Dt NATD 8
|
2000-06-27 11:39:36 +00:00
|
|
|
.Os FreeBSD
|
1997-06-22 04:19:08 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm natd
|
2000-06-27 11:39:36 +00:00
|
|
|
.Nd Network Address Translation Daemon
|
1997-06-22 04:19:08 +00:00
|
|
|
.Sh SYNOPSIS
|
2000-11-20 16:52:27 +00:00
|
|
|
.Nm
|
2000-11-16 12:20:54 +00:00
|
|
|
.Bk -words
|
2000-06-27 11:39:36 +00:00
|
|
|
.Op Fl unregistered_only | u
|
|
|
|
.Op Fl log | l
|
|
|
|
.Op Fl proxy_only
|
|
|
|
.Op Fl reverse
|
|
|
|
.Op Fl deny_incoming | d
|
|
|
|
.Op Fl use_sockets | s
|
|
|
|
.Op Fl same_ports | m
|
|
|
|
.Op Fl verbose | v
|
1997-06-22 04:19:08 +00:00
|
|
|
.Op Fl dynamic
|
2000-06-27 11:39:36 +00:00
|
|
|
.Op Fl in_port | i Ar port
|
|
|
|
.Op Fl out_port | o Ar port
|
|
|
|
.Op Fl port | p Ar port
|
|
|
|
.Op Fl alias_address | a Ar address
|
|
|
|
.Op Fl target_address | t Ar address
|
|
|
|
.Op Fl interface | n Ar interface
|
|
|
|
.Op Fl proxy_rule Ar proxyspec
|
1997-10-18 16:31:28 +00:00
|
|
|
.Op Fl redirect_port Ar linkspec
|
2000-05-03 15:06:45 +00:00
|
|
|
.Op Fl redirect_proto Ar linkspec
|
2000-04-27 17:55:17 +00:00
|
|
|
.Op Fl redirect_address Ar linkspec
|
2000-06-27 11:39:36 +00:00
|
|
|
.Op Fl config | f Ar configfile
|
|
|
|
.Op Fl log_denied
|
|
|
|
.Op Fl log_facility Ar facility_name
|
2000-06-27 15:26:24 +00:00
|
|
|
.Op Fl punch_fw Ar firewall_range
|
2000-11-16 12:20:54 +00:00
|
|
|
.Ek
|
1997-06-22 04:19:08 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
This program provides a Network Address Translation facility for use
|
|
|
|
with
|
|
|
|
.Xr divert 4
|
2000-06-27 11:39:36 +00:00
|
|
|
sockets under
|
|
|
|
.Fx .
|
|
|
|
It is intended for use with NICs - if you want to do NAT on a PPP link,
|
|
|
|
use the
|
|
|
|
.Fl nat
|
|
|
|
switch to
|
1999-04-08 23:15:31 +00:00
|
|
|
.Xr ppp 8 .
|
2000-06-27 11:39:36 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
normally runs in the background as a daemon.
|
|
|
|
It is passed raw IP packets as they travel into and out of the machine,
|
|
|
|
and will possibly change these before re-injecting them back into the
|
|
|
|
IP packet stream.
|
|
|
|
.Pp
|
|
|
|
It changes all packets destined for another host so that their source
|
|
|
|
IP number is that of the current machine.
|
|
|
|
For each packet changed in this manner, an internal table entry is
|
|
|
|
created to record this fact.
|
|
|
|
The source port number is also changed to indicate the table entry
|
|
|
|
applying to the packet.
|
|
|
|
Packets that are received with a target IP of the current host are
|
|
|
|
checked against this internal table.
|
|
|
|
If an entry is found, it is used to determine the correct target IP
|
|
|
|
number and port to place in the packet.
|
1997-06-22 04:19:08 +00:00
|
|
|
.Pp
|
2000-11-16 12:20:54 +00:00
|
|
|
The following command line options are available:
|
1997-06-22 04:19:08 +00:00
|
|
|
.Bl -tag -width Fl
|
|
|
|
.It Fl log | l
|
|
|
|
Log various aliasing statistics and information to the file
|
|
|
|
.Pa /var/log/alias.log .
|
2000-06-27 11:39:36 +00:00
|
|
|
This file is truncated each time
|
|
|
|
.Nm
|
|
|
|
is started.
|
1997-06-22 04:19:08 +00:00
|
|
|
.It Fl deny_incoming | d
|
2000-11-16 12:20:54 +00:00
|
|
|
Do not pass incoming packets that have no
|
2000-06-27 11:39:36 +00:00
|
|
|
entry in the internal translation table.
|
2000-11-16 12:20:54 +00:00
|
|
|
.Pp
|
|
|
|
If this option is not used, then such a packet will be altered
|
|
|
|
using the rules in
|
|
|
|
.Fl target_address
|
|
|
|
below, and the entry will be made in the internal translation table.
|
1999-03-07 18:23:56 +00:00
|
|
|
.It Fl log_denied
|
2000-06-27 11:39:36 +00:00
|
|
|
Log denied incoming packets via
|
|
|
|
.Xr syslog 3
|
|
|
|
.Po
|
|
|
|
see also
|
|
|
|
.Fl log_facility
|
|
|
|
.Pc .
|
1999-03-07 18:23:56 +00:00
|
|
|
.It Fl log_facility Ar facility_name
|
2000-06-27 11:39:36 +00:00
|
|
|
Use specified log facility when logging information via
|
|
|
|
.Xr syslog 3 .
|
|
|
|
Argument
|
|
|
|
.Ar facility_name
|
|
|
|
is one of the keywords specified in
|
|
|
|
.Xr syslog.conf 5 .
|
1997-06-22 04:19:08 +00:00
|
|
|
.It Fl use_sockets | s
|
|
|
|
Allocate a
|
|
|
|
.Xr socket 2
|
2000-06-27 11:39:36 +00:00
|
|
|
in order to establish an FTP data or IRC DCC send connection.
|
|
|
|
This option uses more system resources, but guarantees successful
|
|
|
|
connections when port numbers conflict.
|
1997-06-22 04:19:08 +00:00
|
|
|
.It Fl same_ports | m
|
|
|
|
Try to keep the same port number when altering outgoing packets.
|
2000-06-26 17:18:34 +00:00
|
|
|
With this option, protocols such as RPC will have a better chance
|
2000-06-27 11:39:36 +00:00
|
|
|
of working.
|
|
|
|
If it is not possible to maintain the port number, it will be silently
|
|
|
|
changed as per normal.
|
1997-06-22 04:19:08 +00:00
|
|
|
.It Fl verbose | v
|
2000-06-27 11:39:36 +00:00
|
|
|
Do not call
|
1997-06-22 04:19:08 +00:00
|
|
|
.Xr daemon 3
|
2000-06-27 11:39:36 +00:00
|
|
|
on startup.
|
2000-11-16 12:20:54 +00:00
|
|
|
Instead, stay attached to the controlling terminal and display all packet
|
2000-06-27 11:39:36 +00:00
|
|
|
alterations to the standard output.
|
|
|
|
This option should only be used for debugging purposes.
|
1997-06-22 04:19:08 +00:00
|
|
|
.It Fl unregistered_only | u
|
2000-06-27 11:39:36 +00:00
|
|
|
Only alter outgoing packets with an
|
|
|
|
.Em unregistered
|
|
|
|
source address.
|
|
|
|
According to RFC 1918, unregistered source addresses are 10.0.0.0/8,
|
2000-06-26 17:18:34 +00:00
|
|
|
172.16.0.0/12 and 192.168.0.0/16.
|
2000-06-27 11:39:36 +00:00
|
|
|
.It Fl redirect_port Ar proto Xo
|
|
|
|
.Ar targetIP Ns : Ns Xo
|
|
|
|
.Ar targetPORT Ns Op - Ns Ar targetPORT Xc
|
|
|
|
.Op Ar aliasIP Ns : Ns Xo
|
|
|
|
.Ar aliasPORT Ns Op - Ns Ar aliasPORT Xc
|
|
|
|
.Oo Ar remoteIP Ns Oo : Ns
|
|
|
|
.Ar remotePORT Ns Op - Ns Ar remotePORT
|
|
|
|
.Oc Oc
|
|
|
|
.Xc
|
1999-05-13 16:58:31 +00:00
|
|
|
Redirect incoming connections arriving to given port(s) to another host
|
|
|
|
and port(s).
|
2000-06-27 11:39:36 +00:00
|
|
|
Argument
|
|
|
|
.Ar proto
|
|
|
|
is either
|
|
|
|
.Ar tcp
|
|
|
|
or
|
|
|
|
.Ar udp ,
|
|
|
|
.Ar targetIP
|
|
|
|
is the desired target IP number,
|
|
|
|
.Ar targetPORT
|
|
|
|
is the desired target port number or range,
|
|
|
|
.Ar aliasPORT
|
|
|
|
is the requested port number or range, and
|
|
|
|
.Ar aliasIP
|
|
|
|
is the aliasing address.
|
|
|
|
Arguments
|
|
|
|
.Ar remoteIP
|
|
|
|
and
|
|
|
|
.Ar remotePORT
|
|
|
|
can be used to specify the connection more accurately if necessary.
|
|
|
|
The
|
|
|
|
.Ar targetPORT
|
|
|
|
range and
|
|
|
|
.Ar aliasPORT
|
|
|
|
range need not be the same numerically, but must have the same size.
|
|
|
|
If
|
|
|
|
.Ar remotePORT
|
|
|
|
is not specified, it is assumed to be all ports.
|
|
|
|
If
|
|
|
|
.Ar remotePORT
|
|
|
|
is specified, it must match the size of
|
|
|
|
.Ar targetPORT ,
|
|
|
|
or be 0 (all ports).
|
2000-06-26 17:18:34 +00:00
|
|
|
For example, the argument
|
2000-06-27 11:39:36 +00:00
|
|
|
.Pp
|
1999-06-21 07:58:25 +00:00
|
|
|
.Dl Ar tcp inside1:telnet 6666
|
2000-06-27 11:39:36 +00:00
|
|
|
.Pp
|
|
|
|
means that incoming TCP packets destined for port 6666 on this machine
|
|
|
|
will be sent to the telnet port on the inside1 machine.
|
|
|
|
.Pp
|
1999-06-21 07:58:25 +00:00
|
|
|
.Dl Ar tcp inside2:2300-2399 3300-3399
|
2000-06-27 11:39:36 +00:00
|
|
|
.Pp
|
1999-05-13 16:58:31 +00:00
|
|
|
will redirect incoming connections on ports 3300-3399 to host
|
|
|
|
inside2, ports 2300-2399.
|
|
|
|
The mapping is 1:1 meaning port 3300 maps to 2300, 3301 maps to 2301, etc.
|
2000-06-27 11:39:36 +00:00
|
|
|
.It Fl redirect_proto Ar proto localIP Oo
|
|
|
|
.Ar publicIP Op Ar remoteIP
|
|
|
|
.Oc
|
2000-05-03 15:06:45 +00:00
|
|
|
Redirect incoming IP packets of protocol
|
|
|
|
.Ar proto
|
2000-06-27 11:39:36 +00:00
|
|
|
.Po see Xr protocols 5
|
|
|
|
.Pc
|
2000-05-03 15:06:45 +00:00
|
|
|
destined for
|
|
|
|
.Ar publicIP
|
|
|
|
address to a
|
|
|
|
.Ar localIP
|
|
|
|
address and vice versa.
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Ar publicIP
|
2000-06-26 17:18:34 +00:00
|
|
|
is not specified, then the default aliasing address is used.
|
2000-05-03 15:06:45 +00:00
|
|
|
If
|
|
|
|
.Ar remoteIP
|
2000-06-26 17:18:34 +00:00
|
|
|
is specified, then only packets coming from/to
|
2000-05-03 15:06:45 +00:00
|
|
|
.Ar remoteIP
|
|
|
|
will match the rule.
|
1997-06-22 04:19:08 +00:00
|
|
|
.It Fl redirect_address Ar localIP publicIP
|
2000-06-26 17:18:34 +00:00
|
|
|
Redirect traffic for public IP address to a machine on the local
|
|
|
|
network.
|
2000-06-27 11:39:36 +00:00
|
|
|
This function is known as
|
|
|
|
.Em static NAT .
|
|
|
|
Normally static NAT is useful if your ISP has allocated a small block
|
|
|
|
of IP addresses to you, but it can even be used in the case of single
|
|
|
|
address:
|
|
|
|
.Pp
|
|
|
|
.Dl Ar redirect_address 10.0.0.8 0.0.0.0
|
|
|
|
.Pp
|
2000-06-26 17:18:34 +00:00
|
|
|
The above command would redirect all incoming traffic
|
|
|
|
to machine 10.0.0.8.
|
2000-06-27 11:39:36 +00:00
|
|
|
.Pp
|
2000-06-26 17:18:34 +00:00
|
|
|
If several address aliases specify the same public address
|
|
|
|
as follows
|
2000-06-27 11:39:36 +00:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
.Ar redirect_address 192.168.0.2 public_addr
|
|
|
|
.Ar redirect_address 192.168.0.3 public_addr
|
|
|
|
.Ar redirect_address 192.168.0.4 public_addr
|
|
|
|
.Ed
|
|
|
|
.Pp
|
1997-06-22 04:19:08 +00:00
|
|
|
the incoming traffic will be directed to the last
|
2000-06-26 17:18:34 +00:00
|
|
|
translated local address (192.168.0.4), but outgoing
|
2000-06-27 11:39:36 +00:00
|
|
|
traffic from the first two addresses will still be aliased
|
|
|
|
to appear from the specified
|
|
|
|
.Ar public_addr .
|
2000-04-27 17:55:17 +00:00
|
|
|
.It Fl redirect_port Ar proto Xo
|
|
|
|
.Ar targetIP Ns : Ns Xo
|
|
|
|
.Ar targetPORT Ns Oo , Ns
|
|
|
|
.Ar targetIP Ns : Ns Xo
|
|
|
|
.Ar targetPORT Ns Oo , Ns
|
|
|
|
.Ar ...
|
|
|
|
.Oc Oc
|
|
|
|
.Xc
|
|
|
|
.Xc
|
|
|
|
.Op Ar aliasIP Ns : Ns Xo
|
|
|
|
.Ar aliasPORT
|
|
|
|
.Xc
|
|
|
|
.Oo Ar remoteIP Ns
|
|
|
|
.Op : Ns Ar remotePORT
|
|
|
|
.Oc
|
|
|
|
.Xc
|
|
|
|
.It Fl redirect_address Xo
|
|
|
|
.Ar localIP Ns Oo , Ns
|
|
|
|
.Ar localIP Ns Oo , Ns
|
|
|
|
.Ar ...
|
|
|
|
.Oc Oc
|
|
|
|
.Ar publicIP
|
|
|
|
.Xc
|
|
|
|
These forms of
|
|
|
|
.Fl redirect_port
|
|
|
|
and
|
|
|
|
.Fl redirect_address
|
|
|
|
are used to transparently offload network load on a single server and
|
|
|
|
distribute the load across a pool of servers.
|
|
|
|
This function is known as
|
|
|
|
.Em LSNAT
|
|
|
|
(RFC 2391).
|
2000-06-26 17:18:34 +00:00
|
|
|
For example, the argument
|
2000-04-27 17:55:17 +00:00
|
|
|
.Pp
|
|
|
|
.Dl Ar tcp www1:http,www2:http,www3:http www:http
|
|
|
|
.Pp
|
|
|
|
means that incoming HTTP requests for host www will be transparently
|
2000-06-26 17:18:34 +00:00
|
|
|
redirected to one of the www1, www2 or www3, where a host is selected
|
|
|
|
simply on a round-robin basis, without regard to load on the net.
|
1997-06-22 04:19:08 +00:00
|
|
|
.It Fl dynamic
|
|
|
|
If the
|
|
|
|
.Fl n
|
|
|
|
or
|
|
|
|
.Fl interface
|
|
|
|
option is used,
|
1997-10-02 11:43:33 +00:00
|
|
|
.Nm
|
1997-06-22 04:19:08 +00:00
|
|
|
will monitor the routing socket for alterations to the
|
|
|
|
.Ar interface
|
2000-06-27 11:39:36 +00:00
|
|
|
passed.
|
|
|
|
If the interface's IP number is changed,
|
1997-10-02 11:43:33 +00:00
|
|
|
.Nm
|
1997-06-22 04:19:08 +00:00
|
|
|
will dynamically alter its concept of the alias address.
|
2000-06-27 11:39:36 +00:00
|
|
|
.It Fl in_port | i Ar port
|
1997-06-22 04:19:08 +00:00
|
|
|
Read from and write to
|
2000-11-16 12:20:54 +00:00
|
|
|
.Xr divert 4
|
|
|
|
port
|
2000-06-27 11:39:36 +00:00
|
|
|
.Ar port ,
|
2000-11-16 12:20:54 +00:00
|
|
|
treating all packets as
|
|
|
|
.Dq incoming .
|
2000-06-27 11:39:36 +00:00
|
|
|
.It Fl out_port | o Ar port
|
1997-06-22 04:19:08 +00:00
|
|
|
Read from and write to
|
2000-11-16 12:20:54 +00:00
|
|
|
.Xr divert 4
|
|
|
|
port
|
2000-06-27 11:39:36 +00:00
|
|
|
.Ar port ,
|
2000-11-16 12:20:54 +00:00
|
|
|
treating all packets as
|
|
|
|
.Dq outgoing .
|
2000-06-27 11:39:36 +00:00
|
|
|
.It Fl port | p Ar port
|
1997-06-22 04:19:08 +00:00
|
|
|
Read from and write to
|
2000-11-16 12:20:54 +00:00
|
|
|
.Xr divert 4
|
|
|
|
port
|
1997-06-22 04:19:08 +00:00
|
|
|
.Ar port ,
|
2000-11-16 12:20:54 +00:00
|
|
|
distinguishing packets as
|
|
|
|
.Dq incoming
|
|
|
|
or
|
|
|
|
.Dq outgoing
|
|
|
|
using the rules specified in
|
1997-06-22 04:19:08 +00:00
|
|
|
.Xr divert 4 .
|
|
|
|
If
|
|
|
|
.Ar port
|
|
|
|
is not numeric, it is searched for in the
|
|
|
|
.Xr services 5
|
2000-06-27 11:39:36 +00:00
|
|
|
database.
|
|
|
|
If this option is not specified, the divert port named
|
2000-11-16 12:20:54 +00:00
|
|
|
.Ar natd
|
2000-06-27 11:39:36 +00:00
|
|
|
will be used as a default.
|
|
|
|
.It Fl alias_address | a Ar address
|
1997-06-22 04:19:08 +00:00
|
|
|
Use
|
|
|
|
.Ar address
|
2000-06-27 11:39:36 +00:00
|
|
|
as the aliasing address.
|
|
|
|
If this option is not specified, the
|
1997-06-22 04:19:08 +00:00
|
|
|
.Fl interface
|
2000-06-27 11:39:36 +00:00
|
|
|
option must be used.
|
|
|
|
The specified address is usually the address assigned to the
|
2000-11-16 12:20:54 +00:00
|
|
|
.Dq public
|
|
|
|
network interface.
|
1998-01-29 00:40:41 +00:00
|
|
|
.Pp
|
2000-06-27 11:39:36 +00:00
|
|
|
All data passing
|
|
|
|
.Em out
|
|
|
|
will be rewritten with a source address equal to
|
1998-01-29 00:40:41 +00:00
|
|
|
.Ar address .
|
2000-06-27 11:39:36 +00:00
|
|
|
All data coming
|
|
|
|
.Em in
|
|
|
|
will be checked to see if it matches any already-aliased outgoing
|
|
|
|
connection.
|
|
|
|
If it does, the packet is altered accordingly.
|
|
|
|
If not, all
|
|
|
|
.Fl redirect_port ,
|
|
|
|
.Fl redirect_proto
|
1998-01-29 00:40:41 +00:00
|
|
|
and
|
|
|
|
.Fl redirect_address
|
2000-06-27 11:39:36 +00:00
|
|
|
assignments are checked and actioned.
|
|
|
|
If no other action can be made and if
|
1998-01-29 00:40:41 +00:00
|
|
|
.Fl deny_incoming
|
2000-11-16 12:20:54 +00:00
|
|
|
is not specified, the packet is delivered to the local machine
|
|
|
|
using the rules specified in
|
2000-06-27 11:39:36 +00:00
|
|
|
.Fl target_address
|
|
|
|
option below.
|
2000-05-18 10:31:10 +00:00
|
|
|
.It Fl t | target_address Ar address
|
|
|
|
Set the target address.
|
|
|
|
When an incoming packet not associated with any pre-existing link
|
2000-06-26 17:18:34 +00:00
|
|
|
arrives at the host machine, it will be sent to the specified
|
2000-05-18 10:31:10 +00:00
|
|
|
.Ar address .
|
|
|
|
.Pp
|
|
|
|
The target address may be set to
|
2000-06-27 11:39:36 +00:00
|
|
|
.Ar 255.255.255.255 ,
|
2000-05-18 10:31:10 +00:00
|
|
|
in which case all new incoming packets go to the alias address set by
|
|
|
|
.Fl alias_address
|
|
|
|
or
|
|
|
|
.Fl interface .
|
|
|
|
.Pp
|
2000-06-26 17:18:34 +00:00
|
|
|
If this option is not used, or called with the argument
|
2000-06-27 11:39:36 +00:00
|
|
|
.Ar 0.0.0.0 ,
|
2000-06-26 17:18:34 +00:00
|
|
|
then all new incoming packets go to the address specified in
|
|
|
|
the packet.
|
2000-05-18 10:31:10 +00:00
|
|
|
This allows external machines to talk directly to internal machines if
|
|
|
|
they can route packets to the machine in question.
|
2000-06-27 11:39:36 +00:00
|
|
|
.It Fl interface | n Ar interface
|
1997-06-22 04:19:08 +00:00
|
|
|
Use
|
|
|
|
.Ar interface
|
2000-06-27 11:39:36 +00:00
|
|
|
to determine the aliasing address.
|
|
|
|
If there is a possibility that the IP number associated with
|
1997-06-22 04:19:08 +00:00
|
|
|
.Ar interface
|
|
|
|
may change, the
|
|
|
|
.Fl dynamic
|
2000-06-27 11:39:36 +00:00
|
|
|
option should also be used.
|
|
|
|
If this option is not specified, the
|
1997-06-22 04:19:08 +00:00
|
|
|
.Fl alias_address
|
2000-06-27 11:39:36 +00:00
|
|
|
option must be used.
|
1998-01-29 00:40:41 +00:00
|
|
|
.Pp
|
|
|
|
The specified
|
|
|
|
.Ar interface
|
2000-11-16 12:20:54 +00:00
|
|
|
is usually the
|
|
|
|
.Dq public
|
|
|
|
(or
|
|
|
|
.Dq external )
|
|
|
|
network interface.
|
2000-06-27 11:39:36 +00:00
|
|
|
.It Fl config | f Ar file
|
1997-06-22 04:19:08 +00:00
|
|
|
Read configuration from
|
2000-06-27 11:39:36 +00:00
|
|
|
.Ar file .
|
|
|
|
A
|
|
|
|
.Ar file
|
|
|
|
should contain a list of options, one per line, in the same form
|
|
|
|
as the long form of the above command line options.
|
|
|
|
For example, the line
|
|
|
|
.Pp
|
|
|
|
.Dl alias_address 158.152.17.1
|
|
|
|
.Pp
|
|
|
|
would specify an alias address of 158.152.17.1.
|
2000-11-16 12:20:54 +00:00
|
|
|
Options that do not take an argument are specified with an argument of
|
1997-06-22 04:19:08 +00:00
|
|
|
.Ar yes
|
|
|
|
or
|
|
|
|
.Ar no
|
2000-06-27 11:39:36 +00:00
|
|
|
in the configuration file.
|
|
|
|
For example, the line
|
|
|
|
.Pp
|
|
|
|
.Dl log yes
|
|
|
|
.Pp
|
|
|
|
is synonymous with
|
1997-06-22 04:19:08 +00:00
|
|
|
.Fl log .
|
1999-09-07 15:34:12 +00:00
|
|
|
.Pp
|
|
|
|
Trailing spaces and empty lines are ignored.
|
|
|
|
A
|
|
|
|
.Ql \&#
|
1999-10-30 19:33:41 +00:00
|
|
|
sign will mark the rest of the line as a comment.
|
1999-03-07 18:23:56 +00:00
|
|
|
.It Fl reverse
|
2000-06-27 11:39:36 +00:00
|
|
|
This option makes
|
|
|
|
.Nm
|
2000-11-16 12:20:54 +00:00
|
|
|
reverse the way it handles
|
|
|
|
.Dq incoming
|
|
|
|
and
|
|
|
|
.Dq outgoing
|
|
|
|
packets, allowing it to operate on the
|
|
|
|
.Dq internal
|
|
|
|
network interface rather than the
|
|
|
|
.Dq external
|
|
|
|
one.
|
2000-06-27 11:39:36 +00:00
|
|
|
.Pp
|
|
|
|
This can be useful in some transparent proxying situations
|
|
|
|
when outgoing traffic is redirected to the local machine
|
|
|
|
and
|
|
|
|
.Nm
|
|
|
|
is running on the internal interface (it usually runs on the
|
|
|
|
external interface).
|
1999-03-07 18:23:56 +00:00
|
|
|
.It Fl proxy_only
|
2000-06-27 11:39:36 +00:00
|
|
|
Force
|
|
|
|
.Nm
|
|
|
|
to perform transparent proxying only.
|
2000-03-01 11:27:47 +00:00
|
|
|
Normal address translation is not performed.
|
2000-06-27 11:39:36 +00:00
|
|
|
.It Fl proxy_rule Xo
|
|
|
|
.Op Ar type encode_ip_hdr | encode_tcp_stream
|
|
|
|
.Ar port xxxx
|
|
|
|
.Ar server a.b.c.d:yyyy
|
|
|
|
.Xc
|
2000-03-01 11:27:47 +00:00
|
|
|
Enable transparent proxying.
|
2000-06-27 11:39:36 +00:00
|
|
|
Outgoing TCP packets with the given port going through this
|
2000-06-26 17:18:34 +00:00
|
|
|
host to any other host are redirected to the given server and port.
|
2000-03-01 11:27:47 +00:00
|
|
|
Optionally, the original target address can be encoded into the packet.
|
2000-06-27 11:39:36 +00:00
|
|
|
Use
|
|
|
|
.Ar encode_ip_hdr
|
1999-03-07 18:23:56 +00:00
|
|
|
to put this information into the IP option field or
|
2000-06-27 11:39:36 +00:00
|
|
|
.Ar encode_tcp_stream
|
1999-03-07 18:23:56 +00:00
|
|
|
to inject the data into the beginning of the TCP stream.
|
2000-06-27 15:26:24 +00:00
|
|
|
.It Fl punch_fw Xo
|
|
|
|
.Ar basenumber Ns : Ns Ar count
|
|
|
|
.Xc
|
2000-06-29 09:52:14 +00:00
|
|
|
This option directs
|
2000-06-27 15:26:24 +00:00
|
|
|
.Nm
|
2000-06-29 09:52:14 +00:00
|
|
|
to
|
|
|
|
.Dq punch holes
|
2000-06-27 15:26:24 +00:00
|
|
|
in an
|
|
|
|
.Xr ipfirewall 4
|
|
|
|
based firewall for FTP/IRC DCC connections.
|
2000-06-29 09:52:14 +00:00
|
|
|
This is done dynamically by installing temporary firewall rules which
|
|
|
|
allow a particular connection (and only that connection) to go through
|
|
|
|
the firewall.
|
|
|
|
The rules are removed once the corresponding connection terminates.
|
2000-06-27 15:26:24 +00:00
|
|
|
.Pp
|
2000-06-29 09:52:14 +00:00
|
|
|
A maximum of
|
2000-06-27 15:26:24 +00:00
|
|
|
.Ar count
|
2000-06-29 09:52:14 +00:00
|
|
|
rules starting from the rule number
|
|
|
|
.Ar basenumber
|
|
|
|
will be used for punching firewall holes.
|
2000-06-27 15:26:24 +00:00
|
|
|
The range will be cleared for all rules on startup.
|
1997-06-22 04:19:08 +00:00
|
|
|
.El
|
|
|
|
.Sh RUNNING NATD
|
|
|
|
The following steps are necessary before attempting to run
|
2000-11-20 16:52:27 +00:00
|
|
|
.Nm :
|
1997-06-22 04:19:08 +00:00
|
|
|
.Bl -enum
|
|
|
|
.It
|
|
|
|
Build a custom kernel with the following options:
|
2000-06-27 11:39:36 +00:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
options IPFIREWALL
|
|
|
|
options IPDIVERT
|
|
|
|
.Ed
|
|
|
|
.Pp
|
1997-06-22 04:19:08 +00:00
|
|
|
Refer to the handbook for detailed instructions on building a custom
|
|
|
|
kernel.
|
|
|
|
.It
|
2000-06-27 11:39:36 +00:00
|
|
|
Ensure that your machine is acting as a gateway.
|
|
|
|
This can be done by specifying the line
|
|
|
|
.Pp
|
|
|
|
.Dl gateway_enable=YES
|
|
|
|
.Pp
|
|
|
|
in the
|
|
|
|
.Pa /etc/rc.conf
|
|
|
|
file or using the command
|
|
|
|
.Pp
|
|
|
|
.Dl sysctl -w net.inet.ip.forwarding=1
|
|
|
|
.Pp
|
1997-06-22 04:19:08 +00:00
|
|
|
.It
|
2000-06-27 11:39:36 +00:00
|
|
|
If you use the
|
1997-06-22 04:19:08 +00:00
|
|
|
.Fl interface
|
2000-06-27 11:39:36 +00:00
|
|
|
option, make sure that your interface is already configured.
|
2000-11-16 12:20:54 +00:00
|
|
|
If, for example, you wish to specify
|
|
|
|
.Ql tun0
|
|
|
|
as your
|
1997-06-22 04:19:08 +00:00
|
|
|
.Ar interface ,
|
2000-06-27 11:39:36 +00:00
|
|
|
and you are using
|
1997-06-22 04:19:08 +00:00
|
|
|
.Xr ppp 8
|
2000-06-26 17:18:34 +00:00
|
|
|
on that interface, you must make sure that you start
|
1997-06-22 04:19:08 +00:00
|
|
|
.Nm ppp
|
|
|
|
prior to starting
|
2000-11-20 16:52:27 +00:00
|
|
|
.Nm .
|
1997-06-22 04:19:08 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Running
|
1997-10-02 11:43:33 +00:00
|
|
|
.Nm
|
2000-06-27 11:39:36 +00:00
|
|
|
is fairly straight forward.
|
|
|
|
The line
|
|
|
|
.Pp
|
|
|
|
.Dl natd -interface ed0
|
|
|
|
.Pp
|
|
|
|
should suffice in most cases (substituting the correct interface name).
|
2000-07-17 10:06:54 +00:00
|
|
|
Please check
|
|
|
|
.Xr rc.conf 5
|
|
|
|
on how to configure it to be started automatically during boot.
|
2000-06-27 11:39:36 +00:00
|
|
|
Once
|
1997-10-02 11:43:33 +00:00
|
|
|
.Nm
|
2000-06-27 11:39:36 +00:00
|
|
|
is running, you must ensure that traffic is diverted to
|
2000-11-20 16:52:27 +00:00
|
|
|
.Nm :
|
1997-06-22 04:19:08 +00:00
|
|
|
.Bl -enum
|
|
|
|
.It
|
|
|
|
You will need to adjust the
|
|
|
|
.Pa /etc/rc.firewall
|
2000-06-27 11:39:36 +00:00
|
|
|
script to taste.
|
|
|
|
If you are not interested in having a firewall, the
|
1997-06-22 04:19:08 +00:00
|
|
|
following lines will do:
|
2000-06-27 11:39:36 +00:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
/sbin/ipfw -f flush
|
|
|
|
/sbin/ipfw add divert natd all from any to any via ed0
|
|
|
|
/sbin/ipfw add pass all from any to any
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2000-11-16 12:20:54 +00:00
|
|
|
The second line depends on your interface (change
|
|
|
|
.Ql ed0
|
|
|
|
as appropriate).
|
2000-06-27 11:39:36 +00:00
|
|
|
.Pp
|
|
|
|
You should be aware of the fact that, with these firewall settings,
|
|
|
|
everyone on your local network can fake his source-address using your
|
|
|
|
host as gateway.
|
|
|
|
If there are other hosts on your local network, you are strongly
|
|
|
|
encouraged to create firewall rules that only allow traffic to and
|
|
|
|
from trusted hosts.
|
|
|
|
.Pp
|
|
|
|
If you specify real firewall rules, it is best to specify line 2 at
|
|
|
|
the start of the script so that
|
1997-10-02 11:43:33 +00:00
|
|
|
.Nm
|
1999-10-06 09:26:39 +00:00
|
|
|
sees all packets before they are dropped by the firewall.
|
|
|
|
.Pp
|
|
|
|
After translation by
|
2000-11-20 16:52:27 +00:00
|
|
|
.Nm ,
|
1999-10-06 09:26:39 +00:00
|
|
|
packets re-enter the firewall at the rule number following the rule number
|
2000-06-26 17:18:34 +00:00
|
|
|
that caused the diversion (not the next rule if there are several at the
|
|
|
|
same number).
|
1997-06-22 04:19:08 +00:00
|
|
|
.It
|
|
|
|
Enable your firewall by setting
|
2000-06-27 11:39:36 +00:00
|
|
|
.Pp
|
|
|
|
.Dl firewall_enable=YES
|
|
|
|
.Pp
|
1997-06-22 04:19:08 +00:00
|
|
|
in
|
1997-06-22 14:40:27 +00:00
|
|
|
.Pa /etc/rc.conf .
|
1997-06-22 04:19:08 +00:00
|
|
|
This tells the system startup scripts to run the
|
|
|
|
.Pa /etc/rc.firewall
|
2000-06-27 11:39:36 +00:00
|
|
|
script.
|
|
|
|
If you do not wish to reboot now, just run this by hand from the console.
|
|
|
|
NEVER run this from a remote session unless you put it into the background.
|
|
|
|
If you do, you will lock yourself out after the flush takes place, and
|
|
|
|
execution of
|
1997-06-22 04:19:08 +00:00
|
|
|
.Pa /etc/rc.firewall
|
2000-06-27 11:39:36 +00:00
|
|
|
will stop at this point - blocking all accesses permanently.
|
|
|
|
Running the script in the background should be enough to prevent this
|
|
|
|
disaster.
|
1997-06-22 04:19:08 +00:00
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr divert 4 ,
|
2000-06-27 11:39:36 +00:00
|
|
|
.Xr protocols 5 ,
|
|
|
|
.Xr rc.conf 5 ,
|
1997-06-22 04:19:08 +00:00
|
|
|
.Xr services 5 ,
|
2000-06-27 11:39:36 +00:00
|
|
|
.Xr syslog.conf 5 ,
|
|
|
|
.Xr ipfw 8 ,
|
2000-11-15 16:44:24 +00:00
|
|
|
.Xr ppp 8
|
1997-06-22 04:19:08 +00:00
|
|
|
.Sh AUTHORS
|
|
|
|
This program is the result of the efforts of many people at different
|
|
|
|
times:
|
2000-06-27 11:39:36 +00:00
|
|
|
.Pp
|
1998-03-23 08:31:20 +00:00
|
|
|
.An Archie Cobbs Aq archie@whistle.com
|
|
|
|
(divert sockets)
|
2000-04-02 20:23:34 +00:00
|
|
|
.An Charles Mott Aq cmott@scientech.com
|
1998-03-23 08:31:20 +00:00
|
|
|
(packet aliasing)
|
|
|
|
.An Eivind Eklund Aq perhaps@yes.no
|
|
|
|
(IRC support & misc additions)
|
|
|
|
.An Ari Suutari Aq suutari@iki.fi
|
|
|
|
(natd)
|
1999-03-07 18:23:56 +00:00
|
|
|
.An Dru Nelson Aq dnelson@redwoodsoft.com
|
2000-06-20 12:52:27 +00:00
|
|
|
(early PPTP support)
|
1998-03-23 08:31:20 +00:00
|
|
|
.An Brian Somers Aq brian@awfulhak.org
|
|
|
|
(glue)
|
2000-11-16 12:20:54 +00:00
|
|
|
.An Ruslan Ermilov Aq ru@FreeBSD.org
|
|
|
|
(natd, packet aliasing, glue)
|