home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LINUX / HOWTO / mini / vwuftpd.txt < prev    next >
Text File  |  1997-07-07  |  12KB  |  330 lines

  1.  
  2. Virtual FTP-servers with wu-ftpd           Winfried Trⁿmper <winni@xpilot.org>
  3. --------------------------------           with help from
  4.                                            Brian Grossman <brian@SoftHome.Net>
  5.                                            Version 1.2                27.01.97
  6.  
  7.     
  8.  
  9.   1. Introduction
  10.  
  11.         Linux has the ability to run several "hosts" on one machine.
  12.         Many people already use this to run more than 1 WWW-Service on
  13.         their Linux box, e.g. 
  14.  
  15.                 www.sharpers.com                (192.168.55.37)
  16.                 www.usurers.com                 (192.168.55.38)
  17.                 www.swindlers.com               (192.168.55.39)
  18.  
  19.  
  20.         appear as if they were 3 different hosts but in fact there is
  21.         only one Linux-PC serving them.
  22.  
  23.         The technique behind this feature is called "multihoming" and
  24.         based on the ability of Linux to assign several IP-addresses
  25.         to one network-interface (ethernet-card or modem). In effect,
  26.         you do not need several ethernet-cards to make Linux listen to
  27.         several addresses/hostnames on the net.
  28.         Linux handles the additional IP-addresses through so called 
  29.         "virtual interfaces" which physically represent the same 
  30.         hardware but are logically distinguished with their ip-addresses
  31.         by the software (and the kernel).
  32.  
  33.         Those virtual interfaces are labeled similar than the main
  34.         interface they "point" to and are simply suffixed by a (more or
  35.         less) arbitrary number.
  36.         The proper term for such a virutal interfaces is "ip-alias". For
  37.         the virtual hosts above, the command "ifconfig" gives the (heavily
  38.         edited) output:
  39.  
  40.  
  41.         interface IP-address     broadcast-address       netmask
  42.         ------------------------------------------------------------
  43.         eth0      192.168.55.37    192.168.55.63     255.255.255.224
  44.  
  45.         eth0:0    192.168.55.38    192.168.55.63     255.255.255.224
  46.         eth0:1    192.168.55.39    192.168.55.63     255.255.255.224
  47.         eth0:2    192.168.55.40    192.168.55.63     255.255.255.224
  48.         eth0:3    192.168.55.41    192.168.55.63     255.255.255.224
  49.              ^-- no. of the ip-alias
  50.          
  51.  
  52.         To be able to use the facility of ip-aliases you need a "module"
  53.         for the Linux-kernel that can be fixated into the kernel when
  54.         compiling or loaded at run-time by issuing the command (as root):
  55.  
  56.                 insmod ipalias
  57.  
  58.         Most modern distributions should provide this module so I don't
  59.         want to waste time in describing how to create it (hint: if it's
  60.         missing, read the Linux Kernel-HOWTO).
  61.  
  62.         The ip-aliases for the hosts above are created with a little
  63.         shell-script when booting:
  64.  
  65. 8<----- cut here 8<-----
  66. #!/bin/sh
  67.  
  68. NETMASK="255.255.255.224"      # replace with YOUR netmask
  69. BROADCAST="192.168.55.63"      # replace with YOUR broadcast-address
  70. MAIN_IF="eth0"                 # "main" interface
  71.  
  72. IPALIASES="192.168.55.38   192.168.55.39   192.168.55.40 \
  73.            192.168.55.41   192.168.55.42   192.168.55.43 \
  74.            192.168.55.44   192.168.55.45   192.168.55.46"
  75.  
  76. # you should not need to modify anything below
  77. i=0
  78. for ALIAS in $IPALIASES
  79. do
  80.     /sbin/ifconfig  ${NETTYPE}:${i}  ${ALIAS} \
  81.                     broadcast ${BROADCAST}  netmask ${NETMASK}
  82.     /sbin/route add -host ${ALIAS} dev ${NETTYPE}:${i}
  83.     i=$[$i+1]
  84. done
  85. 8<----- cut here 8<-----
  86.  
  87.  
  88.         If you have further questions about ip-aliases, please look at
  89.         the Linux "IP Alias mini-HOWTO" and the file 
  90.         "Documentation/aliases.txt" from the sources of the Linux-kernel
  91.         (usally in the directory "/usr/src/linux"). 
  92.  
  93.  
  94.  
  95.  
  96.   2. Virtual Services and Servers
  97.  
  98.         If a hostname belongs to an virtual interface, it is commonly
  99.         called "virtual host".
  100.         A daemon that runs a service on a virtual host (or a virtual
  101.         interface) is called "virtual server".
  102.  
  103.  
  104.   2.1. Virtual WWW-Servers
  105.  
  106.         We already had an example for 3 virtual WWW-Servers above:
  107.  
  108.                 www.sharpers.com, www.usurers.com, www.swindlers.com
  109.  
  110.  
  111.         The configuration of all major http-daemons I know (e.g. the
  112.         well-designed "Roxen Challenger" or the widespread "Apache")
  113.         to make use of the virtual hosts is easy and already well
  114.         documented.
  115.         In short: just bind the www-port (no. 80) to the virtual network
  116.         interface with the desired ip-address/hostname for each 
  117.         WWW-server you run. There is no trick.
  118.  
  119.         Read the Linux "Virtual Web mini-HOWTO" to get more information
  120.         on this issue.
  121.  
  122.  
  123.   2.2. Virtual mail-addresses
  124.  
  125.         In the simplest case you want to recieve mail for all your
  126.         virtual hosts and for the dedicated domains:
  127.  
  128.                 www.sharpers.com, www.usurers.com, www.swindlers.com,
  129.                     sharpers.com,     usurers.com,     swindlers.com
  130.  
  131.  
  132.         Even the configuration of "smail" or "sendmail" (the daemons
  133.         that handle the mail-traffic on you Linux-box) is relativly
  134.         easy: mention the additional hostnames/domains in
  135.         "/etc/smail/config" (entries 'hostnames='), resp.
  136.         "/etc/mail/sendmail.cw" (each hostname on a seperate line).
  137.  
  138.         To implement a "real" virtual domain featuring smail, please
  139.         look at the smail-FAQ available from
  140.  
  141.                 http://www.sbay.org/smail-faq.html
  142.  
  143.  
  144.   2.3. Virtual ftp-servers
  145.  
  146.         The concept of a virtual ftp-server is not supported by
  147.         default for any ftp-daemon I know.
  148.  
  149.         What regards to the widespread used daemon "wu-ftpd", there
  150.         is a patch by Brian Grossman <brian@SoftHome.Net> to make the
  151.         anonymous FTP-service distinguish between the virtual 
  152.         interfaces. Availability is mentioned in chapter 3.
  153.  
  154.         There seem to be no other patches around that do the same.
  155.  
  156.  
  157.         The main idea of the Brian's multihome-patch for is to make 
  158.         wu-ftpd "chroot()" to
  159.  
  160.                 HOME_DIRECTORY_OF_ftp-ACCOUNT/HOSTNAME_THE_USER_TALKS_TO/
  161.  
  162.         instead of just doing a chroot() into
  163.  
  164.                 HOME_DIRECTORY_OF_ftp-ACCOUNT/
  165.  
  166.  
  167.         In the example shown below, the user thats connects to
  168.         "ftp.swindlers.com" via anonymous ftp is locked up under
  169.         "/home/ano-ftp/ftp.swindlers.com/" instead of just under
  170.         "/home/ano-ftp/".
  171.         You can imagine that the basic setup is straightforward and
  172.         does not differ much from setting up a single anoymous ftp-account.
  173.  
  174.         Kudos to Brian for this easy and efficient setup-strategy.
  175.  
  176.  
  177.         Let me assume you would already have this special version of
  178.         wu-ftpd compiled youself or fetched the binaries and let me
  179.         postpone all realated questions to the end of this document.
  180.  
  181.         I will give you a real-world example and tell you what I did
  182.         for one of my customers (I only changed the machine names to
  183.         non-existant ones ...).
  184.  
  185.  
  186.     (a) Created a directory "/home/ano-ftp" to incorporate the different
  187.         anonymous ftp-servers.
  188.  
  189.                 mkdir  /home/ano-ftp  &&  cd /home/ano-ftp
  190.                 mkdir  ftp.sharpers.com  ftp.usurers.com  ftp.swindlers.com
  191.  
  192.         Resulting in a tree:
  193.  
  194.         /home/ano-ftp/
  195.                   |-- ftp.sharpers.com
  196.                   |-- ftp.swindlers.com
  197.                   `-- ftp.usurers.com
  198.  
  199.  
  200.     (b) Copied the necessary files for an anonymous ftp-service from the
  201.         already configured anonymous-ftp-directory "/home/ftp" into the
  202.         newly created directories
  203.  
  204.                 cd     /home/ano-ftp/ftp.sharpers.com
  205.                 cp -a  /home/ftp/* .
  206.  
  207.                 cd     ../ftp.swindlers.com
  208.                 cp -a  /home/ftp/* .
  209.  
  210.                 cd     ../ftp.usurers.com
  211.                 cp -a  /home/ftp/* .
  212.  
  213.  
  214.         Don't forget to delete the superfluous files under "pub/"
  215.         afterwards (or simply don't copy them at all).
  216.         For example, the "/home/ftp" the Debian-distribution provides looks
  217.         like 
  218.  
  219.  
  220.         /home/ftp                       Permissions    Owner  Group   Size
  221.                 |-- bin                 d--x--x--x   2 root