%@(#)$Id: redirect.tex,v 1.16 2009/10/22 18:17:09 karls Exp $
%/*
% * Copyright (c) 2001, 2006, 2009
% *      Inferno Nettverk A/S, Norway.  All rights reserved.
% *
% * Redistribution and use in source and binary forms, with or without
% * modification, are permitted provided that the following conditions
% * are met:
% * 1. The above copyright notice, this list of conditions and the following
% *    disclaimer must appear in all copies of the software, derivative works
% *    or modified versions, and any portions thereof, aswell as in all
% *    supporting documentation.
% * 2. All advertising materials mentioning features or use of this software
% *    must display the following acknowledgement:
% *      This product includes software developed by
% *      Inferno Nettverk A/S, Norway.
% * 3. The name of the author may not be used to endorse or promote products
% *    derived from this software without specific prior written permission.
% *
% * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
% * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
% * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
% * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
% * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
% * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
% * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
% * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
% * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
% * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
% *
% * Inferno Nettverk A/S requests users of this software to return to
% *
% *  Software Distribution Coordinator  or  sdc@inet.no
% *  Inferno Nettverk A/S
% *  Oslo Research Park
% *  Gaustadalléen 21
% *  NO-0349 Oslo
% *  Norway
% *
% * any improvements or extensions that they make and grant Inferno Nettverk A/S
% * the rights to redistribute these changes.
% *
% */

\documentclass[a4paper, final, twoside, english]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{html}

\title{\emph{Dante}, Module \emph{Redirect}}
\author{
	Inferno Nettverk A/S \\
	Oslo Research Park   \\
	Gaustadalleen 21	\\
	NO-0349 Oslo          \\
	Norway}
\date{$$$$Date: 2009/10/22 18:17:09 $$$$}

\makeindex

\begin{document}
\maketitle
\thispagestyle{empty}

\clearpage
\setcounter{page}{1}

\section{Description}
 The \emph{Redirect} module gives you control over both
 where clients requests and replies will end up, and
 what addresses and portranges the Dante server will use on behalf
 of the clients for outgoing connections.

 It can be used to redirect clients connections from one address to
 another, useful for cases where you for instance want clients
 to go via a local web-proxy instead of directly to the webserver.

 It can be used to restrict the portranges used by the Dante server,
 useful for cases where a firewall needs to know what portranges
 the Dante server will use.

\section{Syntax}
 The syntax of the \texttt{redirect} statement is as follows:

 \verb"redirect from: <address> to: <address>"

 Either \texttt{from} or \texttt{to} are optional, but at least one
 must be given.

 \texttt{address} are addresses in the usual Dante format.

 As a special short-cut where applicable, if the "to:" address does not
 contain a port-specifier, the Dante server will use the same port as in
 the original socks-request where applicable.

 This makes it possible to redirect all connections to one given host,
 to another given host, without having to specify one redirect statement
 for each portnumber, and is applicable to the \texttt{connect} and
 \texttt{udpassociate} commands.

\section{Semantics}
 The \texttt{redirect} statement integrates as a part of socks-rules.

 The meaning of \texttt{to} and \texttt{from} varies considerably
 depending on what socks \texttt{command} the \texttt{redirect}
 statement applies to.

 The next section will detail the semantics of each \emph{redirect}
 application based on the \texttt{command} used (with the corresponding
 \texttt{protocol} in parenthesis, for those preferring using that).

 \subsection{\texttt{bind} (\texttt{protocol: tcp})}
  \texttt{from} is the address to bind on behalf of the client. \\
  \texttt{to} is ignored.

 \subsection{\texttt{bindreply} (\texttt{protocol: tcp})}
  \texttt{from} is the address to tell the client the bindreply (connection)
	is from. \\
  \texttt{to} is the address to send the bindreply (connection) to.

 \subsection{\texttt{connect} (\texttt{protocol: tcp})}
  \texttt{from} is the address to use on behalf of the client for making
	the connection. \\
  \texttt{to} is the address to connect the client to.

 \subsection{\texttt{udpassociate} (\texttt{protocol: udp})}
  \texttt{from} is the address to use on behalf of the client
	for sending udp packets. \\
  \texttt{to} is the address to send packets from the client to.

 \subsection{\texttt{udpreply} (\texttt{protocol: udp})}
  \texttt{from} is the address to tell the client the reply is from. \\
  \texttt{to} is the address to send the reply to.

\section{Examples}
 This section shows several examples of how one could use the
 \emph{redirect} module.

 \subsection{Redirecting web-requests to a web proxy}
  The below rule redirects clients from the \texttt{10.0.0.0/24} net who
  want to connect to the http port of any address to the address
  \texttt{squid.example.com}, port \texttt{3128}.

  \begin{verbatim}
pass {
   from: 10.0.0.0/24 to: 0.0.0.0/0 port = http
   command: connect
   redirect to: squid.example.com port = 3128
}
  \end{verbatim}

 \subsection{Limiting the portranges used by the \emph{Dante} server}
  The next rule says that the server should limit itself to
  using portranges above \texttt{32768} on the interface
  \texttt{de1} when sending packets out on behalf of the
  clients on the \texttt{10.1.1.0/24} net.

  \begin{verbatim}
pass {
   from: 10.0.0.0/24
   redirect from: de1 port > 32768
}
  \end{verbatim}

\end{document}
