Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm totally new to iptables but I need it to allow only ftp access to ftp.mywebsite.com, and refuse the ftp connection to other domain/ip (by closing the port?).

Is this possible? how can I do that?

I googled for it but couldn't find a solution.

Thanks for your help :)

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted
iptables -I FORWARD -p tcp -d ftp.mywebsite.com --dport 21 -j ACCEPT
iptables -I FORWARD -p tcp --dport 21 -j REJECT

If you are not on a firewall system and you want to use the local iptables, it have to look like this:

iptables -I OUTPUT -p tcp -d ftp.mywebsite.com --dport 21 -j ACCEPT
iptables -I OUTPUT -p tcp --dport 21 -j REJECT
share|improve this answer
    
Thanks for the answer! What do you mean by "not on a firewall system ?" I will use the iptable from my only one server. –  Cyril N. Jul 1 '11 at 12:10
    
@cx42net You could have a dedicated firewall system / router. In your case, use the second one –  Thomas Berger Jul 1 '11 at 12:14
    
Thanks for the precision! :) –  Cyril N. Jul 1 '11 at 12:34
    
I've got an error when I write the first line of the second solution : "iptables: No chain/target/match by that name.". Do you know why? –  Cyril N. Jul 1 '11 at 13:48
    
@cx42net make sure you have installed the iptables packages of your distribution and the kernel modules are present. If they are missing, you will get an error like this. –  Thomas Berger Jul 1 '11 at 13:58
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.