#
# FAQ
#
# portfwd - Port Forwarding Daemon
#
# $Id: FAQ,v 1.4 2002/05/05 05:27:49 evertonm Exp $
#


Q: How to enable load balancing?

A: There are two approaches:

   1. By using "on-the-fly DNS"

      Assign multiple addresses to a DNS name, use a such name as a
      single destination in Portfwd configuration and then run Portfwd
      in on-the-fly DNS mode with the "-f" switch.

      /*
       * Load-balacing example with DNS on-demand
       */
      tcp {
	 80 { => multiple-addresses-hostname:8080 }
      }

      The DNS service will make Portfwd to scan, in a round-robin
      fashion, all addresses assigned to that name.

      One problem with this method is the time spent to query the DNS
      system.

   2. By specifying multiple destinations 

      As of version 0.23, Portfwd supports multiple
      destinations. Thus, one may write rules like:

      /*
       * Load-balacing example with multiple destinations
       */
      tcp {
	 80 { => host1:8080, host2:80, host2:80, host3:80 }
      }

      In this example, 1/4 of the connections are forwarded
      to host1:80, 2/4 to host2:80 and 1/4 to host3.

   It's also possible to combine both methods.


Q: How to bind to a specific address?

A1: If you want to specify a local address for incoming
    connections, use the "listen-on" statement. In previous
    Portfwd versions, such option was known as "bind-address".

        /* 
	 * listen-on example
	 */

        listen-on 10.0.0.1 /* uses 10.0.0.1 until next listen-on */
        tcp {
          2323 { => 10.0.0.2:23 };
          8080 { => 10.0.0.2:80 }
        }
        udp { 6000 { => 192.168.0.2:6000 } }

        listen-on 192.168.0.1 /* from here afterwards, use 192.168.0.1 */
        tcp {
          2323 { => 10.0.0.3:23 };
          2525 { => 192.168.0.2:25 }
        }


A2: If you want to specify a local source address for
    outgoing connections, use the "source-address" statement.
    Please notice this option overrides the transparent
    proxying.

	/*
	 * source-address example
	 */

	tcp { 10000 { => localhost:15000 } }
	udp { 10000 { => localhost:15000 } }

        /* Above the source-address line, the system
           automatically selects the source address
           for outgoing connections. */

	source-address 10.0.0.2

        /* Below the source-address line, the address
           specified is used as source address
           for outgoing connections. Of course, that
           address must be previously assigned to a
           local interface. */

	tcp { 11000 { => localhost:15000 } }
	udp { 11000 { => localhost:15000 } }


Q: How does FTP forwarding work?

A: See the example below.

	 ----------      -----------      ---------- 
	 | FTP    |      | portfwd |      | FTP    |
	 | client |      | host    |      | server |
	 ----------      -----------      ----------
	      |           |       |            |
	 -----------...------   ------...-----------
	      a           b       c            d

        b = name/address of client-side interface 
	c = name/address of server-side interface
	
	tcp {
		2121
		ftp-active-mode-on c
		ftp-passive-mode-on b
		{ => d:21 }
	}


Q: How can I debug Portfwd behavior?

A: Append the "-d" switch to Portfwd command 
   line and then watch your logs. 

	Example:
	echo "daemon.* /var/log/daemon.log" >> /etc/syslog.conf
	touch /var/log/daemon.log
	/etc/rc.d/init.d/syslog restart
	tail -f /var/log/daemon.log
	portfwd -d -c <your_config_file>


				 -x-
