home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Online / TCPProxy / tcpproxy.nroff < prev   
Text File  |  2000-08-23  |  9KB  |  199 lines

  1. tcpproxy  -  generic TCP proxy server ttccpppprrooxxyy [_o_p_t_i_o_n_s] [_s_e_r_v_e_r]
  2. is a generic TCP proxy server.  It connects a client and a server
  3. and forwards any data from the client to the server and vice ver-
  4. sa.  _t_c_p_p_r_o_x_y doesn't care about the data being transported.   If
  5. _s_e_r_v_e_r  begins  with  a  `/' or `.' it's taken as a pathname to a
  6. program that acts as a request handler for incoming  connections.
  7. Otherwise _s_e_r_v_e_r is interpreted as _h_o_s_t[:_p_o_r_t] and the client re-
  8. quest is forwarded to the given _h_o_s_t and _p_o_r_t.  If in  this  case
  9. _p_o_r_t is omitted _t_c_p_p_r_o_x_y uses it's own server port as destination
  10. port on _h_o_s_t.  If _t_c_p_p_r_o_x_y has to start a local  program  it  set
  11. the    environment    variables    PPRROOXXYY__PPOORRTT,   PPRROOXXYY__IINNTTEERRFFAACCEE,
  12. PPRROOXXYY__CCLLIIEENNTT and PPRROOXXYY__CCLLIIEENNTTNNAAMMEE with the data  of  the  current
  13. connection.   The  `PROXY_' prefix might be changed with the com-
  14. mand line option --vv or the sseetteennvv configuration  directive.   can
  15. be either started from or act as a standalone server listening an
  16. several ports.  If the _s_e_r_v_e_r argument is missing _t_c_p_p_r_o_x_y  reads
  17. it's  configuration  file  _/_e_t_c_/_t_c_p_p_r_o_x_y_._c_o_n_f and either forwards
  18. the current connection or binds to the  specified  ports  waiting
  19. for  client requests.  The following directives define the global
  20. configuration.  ssttaannddaalloonnee [yyeess|nnoo] if set to  `yes'  the  server
  21. binds to the defined ports waiting for requests.  This is the de-
  22. fault if a configuration file is used.  The uuiidd and ggiidd  settings
  23. are  only  used  if the user starting _t_c_p_p_r_o_x_y is rroooott, otherwise
  24. they are ignored.  If however the calling user  is  rroooott  and  no
  25. settngs  are  found _t_c_p_p_r_o_x_y uses it's internal default of -1 and
  26. -2 for the user and group id.  _t_c_p_p_r_o_x_y won't run as  root.   The
  27. following  directives control the available services and how they
  28. are served.  ppoorrtt _p_o_r_t_-_n_u_m_b_e_r defines a new port  where  _t_c_p_p_r_o_x_y
  29. should  accept  client  requests.  iinntteerrffaaccee _i_p_-_n_u_m_b_e_r defines an
  30. interface on which connections on the service port from the  last
  31. ppoorrtt  directive  are  handled.   sseerrvveerr _s_e_r_v_e_r[:_p_o_r_t] defines the
  32. server and port where _t_c_p_p_r_o_x_y will forward an  incoming  connec-
  33. tion to.  If _p_o_r_t is ommited the listening _t_c_p_p_r_o_x_y port is used.
  34. uuiidd _n_u_m_e_r_i_c_-_u_i_d defines the numeric user  id  to  which  _t_c_p_p_r_o_x_y
  35. changes  after accepting a requests.  ggiidd _n_u_m_e_r_i_c_-_g_i_d same as uuiidd
  36. but for the group id.  eexxeecc _c_o_m_m_a_n_d defines a local command which
  37. is  executed  to  handle  a request.  aaccpp _p_r_o_g_r_a_m sets the access
  38. control program that is used to grant or  deny  incoming  connec-
  39. tions.   llooggnnaammee  _n_a_m_e  sets  a  different  syslog  name.  sseetteennvv
  40. _v_a_r_p_r_e_f_i_x defines the variable prefix.  ttiimmeeoouutt _t_i_m_e_o_u_t defines a
  41. different  timeout  in seconds than the default of 60.  wwrriitteeffiillee
  42. _f_i_l_e_n_a_m_e defines the basename for files where  the  server/client
  43. communication  is  written.   For  a service configuration either
  44. sseerrvveerr or eexxeecc must be specified.  The _t_i_m_e_o_u_t value is only used
  45. in  conjunction with a _s_e_r_v_e_r configuration and _v_a_r_p_r_e_f_i_x only if
  46. requests are handled by a local program.  ttiimmeeoouutt, sseetteennvv amd aaccpp
  47. define  configuration  defaults  if  they appear before the first
  48. ppoorrtt directive.  In version 1.1.5 the way user and group id's are
  49. handled  changed.  From version 1.1.5 these ids are changed after
  50. accepting a request and not after binding to all ports before ac-
  51. cepting  anything.   This is however only done if _t_c_p_p_r_o_x_y's user
  52. id is 0, otherwise _t_c_p_p_r_o_x_y keeps  it's  current  ids.   The  ids
  53. which  are used for a service request are written to syslog.  The
  54. default values for uid/gid are  65535/65534  which  is  equal  to
  55. -1/-2.   If for a port configuration an access control program is
  56. set this program is executed before forwarding the request.   The
  57. acp  can then decide if it grants (exit status 0) or denies (exit
  58. status not 0) the access.  The acp can additionaly print a  diag-
  59. nostic  message  to  the  requesting client through it's standard
  60. output and to the _t_c_p_p_r_o_x_y  through  it's  standard  error.   The
  61. PPRROOXXYY__  variables are set for the current connection when the acp
  62. is called.  The following options are available: --aa _p_r_o_g_r_a_m  sets
  63. _p_r_o_g_r_a_m  as  access  control  program.  --bb [_i_n_t_e_r_f_a_c_e:]_p_o_r_t tells
  64. _t_c_p_p_r_o_x_y that it should bind to _p_o_r_t on the given _i_n_t_e_r_f_a_c_e.   If
  65. _i_n_t_e_r_f_a_c_e  is  omitted _t_c_p_p_r_o_x_y will bind to all available inter-
  66. faces.  --bb implies --ss.  --ff _c_o_n_f_i_g sets a different  configuration
  67. file  than  _/_e_t_c_/_t_c_p_p_r_o_x_y_._c_o_n_f.   --ll  _l_o_g_n_a_m_e sets the name under
  68. which  _t_c_p_p_r_o_x_y  writes  to  syslog.   --pp  creates  the   pidfile
  69. _/_v_a_r_/_r_u_n_/_t_c_p_p_r_o_x_y_._p_i_d.   This default name can be changed by giv-
  70. ing the --pp option twice followed by the name of the pidfile.   --ss
  71. sets  standalone (bind to ports and listen) mode.  --tt _t_i_m_e_o_u_t de-
  72. fines a different _t_i_m_e_o_u_t in seconds than the default of 60  sec-
  73. onds  for  each  connection.   --vv _v_a_r_p_r_e_f_i_x specifies a different
  74. variable prefix than `PROXY_' for the request handler  variables.
  75. --ww  _w_r_i_t_e_f_i_l_e  specifies  that the client/server communication is
  76. written to the file _w_r_i_t_e_f_i_l_e.pid.log.  --yy clears the whole envi-
  77. ronment  before  starting the request handler.  lists the config-
  78. ured server ports and exits.  This is useful if you want to shut-
  79. down  the  tcpproxy  services with either _f_u_s_e_r(1) or _n_e_t_u_s_e_r(1).
  80. Giving --zz twice lists the basic configuration data.  In case that
  81. the --bb option is found on the command line the _s_e_r_v_e_r argument is
  82. expected.  The following examples assume  that  _t_c_p_p_r_o_x_y  is  in-
  83. stalled  on  a  machine with two network interface cards.  One is
  84. the external interface with the IP number  192.44.100.7  and  the
  85. other  is  the  internal  one  with  IP  numbers  192.168.1.1 and
  86. 192.168.1.2 (virtual interfaces).
  87.  
  88.       #
  89.       # /etc/tcpproxy.conf - sample configuration
  90.       #
  91.  
  92.       #
  93.       # Define SMTP proxys ...
  94.       #
  95.       port 25
  96.  
  97.         # ... for outgoing ...
  98.         #
  99.         interface 192.168.1.1
  100.           server mailrelay.provider.com
  101.  
  102.         # ... and incoming email.
  103.         #
  104.         interface 192.44.100.7
  105.           server mail.domain.com
  106.  
  107.       #
  108.       # There are also NNTP-Servers on the outside
  109.       #
  110.       port 119
  111.  
  112.          interface 192.168.1.1
  113.            server nntp.provider.com
  114.  
  115.          interface 192.168.2.1
  116.            server nntp.other-provider.com
  117.  
  118.       #
  119.       # Users from the outside can access our internal
  120.       # POP3 server ...
  121.       #
  122.       port 110
  123.  
  124.         interface 192.44.100.7
  125.  
  126.         # ... but only trough a real application gateway.
  127.         #
  128.         exec /usr/local/sbin/pop3.proxy mail.domain.com
  129.  
  130. With this configuration file _t_c_p_p_r_o_x_y might be started with
  131.  
  132.      tcpproxy -s
  133.  
  134. to make tcpproxy bind itself to all the listed  interfaces.   An-
  135. other  way  of  serving  requests  is  to  configure the ports in
  136. _/_e_t_c_/_i_n_e_t_d_._c_o_n_f and start _t_c_p_p_r_o_x_y without  the  --ss  option  from
  137. there.   The  proxy  will then inspect it's configuration file to
  138. see how the connection made by _i_n_e_t_d should be handled.  tcpproxy
  139. -b  192.44.100.7:79 /bin/date opens a date server on the external
  140. interface.  This service won't be  available  on  the  interfaces
  141. numbered  192.168.1.1  and .2 but the service is still accessable
  142. from the internal network:
  143.  
  144.       user@192.168.1.10/~ > telnet 192.44.100.7 79
  145.       <current date goes here>
  146.  
  147. If in inetd mode you want to provide a service only on  one  net-
  148. work  card  you'll  have to implement further access control with
  149. packet filters.  _t_c_p_p_r_o_x_y doesn't forward the FTP  protocol;  use
  150. _f_t_p_._p_r_o_x_y  for this.  It doesn't work with UDP protocols too, TCP
  151. uses connection and UDP not - this  is  an  imortant  difference.
  152. And  furthermore _t_c_p_p_r_o_x_y doesn't protect you against network at-
  153. tacks like buffer overflows against the addressed server.  You'll
  154. have to use application gateway level proxys for that.
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.