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

I have a VPS box with 4 external ips on it and I need to open the udp port for each ip in part but I can't seem to get it right with ip tables. Here's my rule so far:

iptables -I INPUT -d -p udp --dport 34121 -j ACCEPT

The program I'm using needs to connect to that ip via udp but the server does not allow it. any ideas?

share|improve this question
First, are you sure it's UDP? second, are you sure you don't need a rule in the OUTPUT chain? – Olipro Jul 25 '11 at 2:17
I'm sure it's udp. Second, I'm not sure :) – Romeo M. Jul 25 '11 at 2:28
Are you sure your application listen on this IP or something like ? – Mr.Hien Jul 25 '11 at 3:28
iptables -I INPUT requires entry number. – poige Jul 25 '11 at 5:48

Have you turned off the firewall altogether just to confirm that what you want to do will work? If it works with out it then at least you know its your rule, if it does not then there is something else going on that is causing the problem.

share|improve this answer
Yeah I tried that and it doesn't work. I think it has something to do with the ip not being the main server ip. – Romeo M. Jul 25 '11 at 1:54
Are you running anything like SE Linux on the server? I have run into problems kinda like this when I have used SE Linux in the past. – enterzero Jul 25 '11 at 1:59

If you don't need to limit your destination IP, you can safely drop -d. You do, however, need to match the protocol with "-m". So you need to do this:

iptables -I INPUT 1 -m udp -p tcp --deport 32121 -j ACCEPT (for Red Hat / Centos 5)


iptables -I INPUT 5 -m udp -p tcp --deport 32121 -j ACCEPT (for Red Hat / Centos 6)

At any event, if you are still unable to connect, try running a snoop or tcpdump on the interfaces to verify that you have two-way traffic.

share|improve this answer
"-m udp" is equivalent to "-p udp". He had it right in the question. – Handyman5 Jul 25 '11 at 5:21

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.