The only way that I'm aware of how to easily do this is iptables directly:
Code:
/sbin/iptables -I INPUT -d serverdedIP# -p tcp -m tcp --dport 21 -j DROP
/sbin/iptables -I INPUT -s customerIP# -d serverdedIP# -p tcp -m tcp --dport 21 -j ACCEPT
Replace customerIP# with the IP for the customer's local IP he'll be connecting with to the FTP service. Replace serverdedIP# with the server's dedicated IP for the FTP site on the machine.
For the above to explain what is being done, here is what each rule means:
Rule 1:
/sbin/iptables ==> put into iptables
-I ==> an insert rule at the top of the chain
INPUT ==> the INPUT or incoming chain filter
-d serverdedIP# ==> for the destination IP
-p tcp -m tcp ==> on TCP
--dport 21 ==> destination port 21 for FTP
-j DROP ==> jump to the DROP state
Rule 2:
/sbin/iptables ==> put into iptables
-I ==> an insert rule at the top of the chain
INPUT ==> the INPUT or incoming chain filter
-s customerIP# ==> for the source IP (originating IP)
-d serverdedIP# ==> for the destination IP
-p tcp -m tcp ==> on TCP
--dport 21 ==> destination port 21 for FTP
-j ACCEPT ==> jump to the ACCEPT (allow) state
Now, the reason I have two insert rules for your INPUT chain is that I have no idea if you forward the INPUT chain in another rule to another table (CSF does this as do the default RedHat servers), so in order to offset any possible forwarding to another chain from INPUT after the first line, I had to force these rules into that chain before a possible forward. To do that, I used -I which puts the rules I have at the top. To ensure that the one IP is whitelisted for the customer connecting, I put that rule second, since it will insert at the top after the DROP rule based on the order I'm having them entered. Please ensure that the DROP rule is added first and the ACCEPT second in this situation. If the DROP is done second, then you'll block everyone on that IP for FTP services.
Once you've done the rules and checked it works, you can save the rules so they'll stick on server reboot:
Code:
service iptables save
I did test these rules on a machine of mine and it worked properly to restrict FTP access from every other IP besides my local computer:
My local system (the IP I had whitelisted in the firewall) connecting to my dedicated IP for FTP
Code:
$ ftp 67.210.103.23
Connected to 67.210.103.23.
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 2 of 50 allowed.
220-Local time is now 05:49. Server port: 21.
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Two of my test machines that weren't whitelisted to connect to that dedicated IP for FTP
Code:
[root@scratchy:~] # ftp 67.210.103.23
ftp: connect: Connection timed out
Code:
[root@itchy:~] # ftp 67.210.103.23
ftp: connect: Connection timed out
One other point I wanted to cover since the original thread opener mentioned it, the service listed for WHM > Host Access Control (which controls /etc/hosts.allow file) is not PURE-FTPD nor pure-ftpd but ftp only. If you start typing in WHM > Host Access Control the letters ft, then you'll see it provide the suggestion to use ftp for the service's name. To block all access to all FTP on a machine using Host Access Control for all IPs but select ones, it would be the following:
Code:
Daemon Access List Action Comment
ftp MyIP# allow
ftp ALL deny