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.

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 98.158.xxx.86 -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 0.0.0.0 ? –  Mr.Hien Jul 25 '11 at 3:28
1  
iptables -I INPUT requires entry number. –  poige Jul 25 '11 at 5:48
add comment

2 Answers

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
add comment

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)

or

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
add comment

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.