Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I'd like to stop others from seeing my ports as filtered in the nmap standard scan (unprivileged). Let's say that I have the following ports open: 22, 3306, 995 and a firewall configured like this:

-A INPUT -p tcp -m tcp --dport 22 -j DROP
-A INPUT -p tcp -m tcp --dport 3306 -j DROP
-A INPUT -p tcp -m tcp --dport 995 -j DROP

This is the result of an nmap scan:

[+] Nmap scan report for X.X.X.X

    Host is up (0.040s latency).
    Not shown: 90 closed ports

    PORT     STATE    SERVICE
    22/tcp   filtered ssh
    995/tcp  filtered pop3s
    3306/tcp filtered mysql

It displays these ports as filtered, because my server didn't reply RST for SYN. Is there a way to modify this behaviour? For example: if the iptables firewall blocks a port, reply RST for SYN, instead of remaining silent (not replying anything)?

share|improve this question
up vote 18 down vote accepted

Don't use DROP, that's easily identified as "filtered" if you know the box is up. Instead, you may use the following to send a RST. (as if there is a service listening, but it doesn't accept connections from you)

-A INPUT -p tcp -m tcp --dport 22 -j REJECT --reject-with tcp-reset

Or otherwise simply use the following to make the port look closed. (as if there is no service listening on it)

-A INPUT -p tcp -m tcp --dport 22 -j REJECT
share|improve this answer
-A INPUT -p tcp -m tcp --dport 995 -j REJECT --reject-with tcp-reset

should be doing what you want (reply with RST).

share|improve this answer

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.