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'm having a problem here, I've added to my IPtables rules this:

-A INPUT -p tcp -m state --state NEW -m tcp --dport 161 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 161 -j ACCEPT

but when I scan with nmap or any other tool it says this:

Not shown: 998 filtered ports
22/tcp  open   ssh
161/tcp closed snmp

also when I am doing:

netstat -apn | grep snmpd
tcp        0      0     *                   LISTEN      3669/snmpd<br>
udp        0      0       *                               3669/snmpd<br>
unix  2      [ ]         DGRAM                    226186 3669/snmpd


service iptables status

Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     all  --             state RELATED,ESTABLISHED
2    ACCEPT     icmp --  
3    ACCEPT     all  --  
4    ACCEPT     tcp  --             state NEW tcp dpt:161
5    ACCEPT     udp  --             state NEW udp dpt:161
6    ACCEPT     tcp  --             state NEW tcp dpt:22
7    REJECT     all  --             reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination
1    REJECT     all  --             reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

Any idea what's going on? There is no UDP in closed/open state. what do I have to do?

share|improve this question
What nmap command did you use? Did you have the -sU option set? – Ladadadada Nov 23 '12 at 10:30
Ladadadada is right. But probably you are working with a wrong community, this is why doesn't work. – Sacx Nov 23 '12 at 11:36
I am using the nmap -sT -O IP_ADDR but with nmap -sU -O IP_ADDR i don't take any response for a long time. – anksoWX Nov 23 '12 at 11:46

By default, snmpd listens to UDP port 161 on all interfaces. If you want to use TCP, you will have to configure that in your snmpd.conf or in /etc/default/snmpd.

The fact that nmap sees port 161 as "closed" rather than "filtered" means that it got a RST packet in return when it tried to contact TCP port 161 rather than getting nothing back. This means that your IPTables rules are working fine.

share|improve this answer
Also i've removed the ip table rule for TCP and i leaved only the UDP rule. Now it doesn't response at all. – anksoWX Nov 23 '12 at 11:47

Your Answer


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.