1 This example shows how you might set up virtual hosts. Virtual hosting is
2 where different clients access your machine on different IP addresses (virtual
3 IPs) and get redirected to different ftp sites.
5 For example, if your machine responds to two IPs - 127.0.0.1 and 127.0.0.2,
6 you could have the two different IPs represent two totally different FTP sites.
8 For this example, we are going to build on the "INTERNET_SITE" example.
10 Step 1) Set up a virtual IP address.
12 ifconfig eth0:1 192.168.1.10 up
13 (the standard IP address is 192.168.1.2)
14 (note - this isn't quite complete, the route for local connects hasn't been
15 added, but it will do for now)
18 Step 2) Create a user / location for the new virtual site.
20 useradd -d /var/ftp_site2 ftp_site2
21 chown root.root /var/ftp_site2
22 chmod a+rx /var/ftp_site2
24 mkdir /var/ftp_site2/pub
25 echo "test" > /var/ftp_site2/pub/content
28 Step 3) Modify the existing site to respond to the primary IP.
30 Edit /etc/xinetd.d/vsftpd, and add the config line:
35 Step 4) Create the new site, responding on the virtual IP.
37 cp /etc/xinetd.d/vsftpd /etc/xinetd.d/vsftpd2
39 Edit vsftpd2, and change
40 - The bind line to refer to the IP address 192.168.1.10
42 server_args = /etc/vsftpd_site2.conf
44 This launches this FTP site with a different vsftpd configuration file.
46 cp /etc/vsftpd.conf /etc/vsftpd_site2.conf
49 ftp_username=ftp_site2
50 ftpd_banner=This is the alternative FTP site.
53 Step 5) Restart xinetd and test!
55 /etc/rc.d/init.d/xinetd restart
57 [chris@localhost vsftpd]$ ftp 192.168.1.2
58 Connected to 192.168.1.2 (192.168.1.2).
59 220 ready, dude (vsFTPd 1.1.0: beat me, break me)
60 Name (192.168.1.2:chris): [chris@localhost vsftpd]$
61 [chris@localhost vsftpd]$ ftp 192.168.1.2
62 Connected to 192.168.1.2 (192.168.1.2).
63 220 ready, dude (vsFTPd 1.1.0: beat me, break me)
64 Name (192.168.1.2:chris):
65 530 This FTP server is anonymous only.
70 [chris@localhost vsftpd]$ ftp 192.168.1.10
71 Connected to 192.168.1.10 (192.168.1.10).
72 220 This is the alternative FTP site.
73 Name (192.168.1.10:chris):
74 530 This FTP server is anonymous only.