Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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.

    
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

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

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