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.

This question already has an answer here:

Hi all into my ubuntu server I want to block the ftp port for all except my ip: 123.123.123.123

How is possible this?

share|improve this question
    
What have you tried so far? Have you read the manpage? –  MDMarra Jun 6 '13 at 12:18
    
Yes but I wanna be sure what I set into iptables because I have a lot of site into this server –  Alessandro Minoccheri Jun 6 '13 at 12:19
add comment

marked as duplicate by MDMarra, Dennis Kaarsemaker, Chris S Jun 6 '13 at 13:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

Write a rule which blocks all the incoming traffic for FTP, assuming the FTP port is 21:

iptables -A INPUT -p tcp --destination-port 21 -j DROP

Then write the following rule to exclude your IP from being blocked:

iptables -I INPUT -s 123.123.123.123 -p tcp --destination-port 21 -j ACCEPT

The -I parameter will insert the rule at the top of the stack. Since we didn't provide any rule number, it will be inserted at the top by default.

share|improve this answer
    
If I write the first iptables return me No chain/target/match by that name why? what is wrong? –  Alessandro Minoccheri Jun 6 '13 at 13:09
add comment

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