port redirection help !!

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
hellbound1988
DD-WRT User


Joined: 20 Apr 2009
Posts: 66

PostPosted: Sat Mar 26, 2011 9:12    Post subject: port redirection help !! Reply with quote
I have a TP-link WR941ND running 16214 build. I have a asterisk server running behind dd-wrt.So clients from the internet register to server via udp 5060 port. But for some clients udp 5060 is blocked so i want to redirect a specific subnet from a random udp port say 1600 to udp 5060 so that the request they made using their open udp port (1600) ultimately seen coming from udp 5060 by asterisk thus allowing them to register.

I have already read the wiki but found no clue about redirection of ports from wan. Any ideas ?
Sponsor
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Sat Mar 26, 2011 20:30    Post subject: Reply with quote
Use port forwarding, it's on the wiki.
_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
hellbound1988
DD-WRT User


Joined: 20 Apr 2009
Posts: 66

PostPosted: Sun Mar 27, 2011 22:12    Post subject: Reply with quote
i couldn't find any redirect command on wiki. However i tried with this

iptables -t nat -I PREROUTING --src 113.231.122.0/24 --dst 192.168.1.5 -p udp --dport 1600 -j REDIRECT --to-ports 5060

192.168.1.5 is the local ip of my voice box
here from the client's subnet 113.231.122.0/24 the user requests to connect to my voip box 192.168.1.5 using port udp 1600 which is open for them. Router then redirect the udp 1600 traffic to udp 5060. Is that correct ? I guess i also have to add a rule for the outgoing packet too ? Also normal clients connect to my server by mentioning domain name which is the wan ip of my router. Do the specific user should use 192.168.1.5 as their register server or my wan ip ?
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Mon Mar 28, 2011 9:26    Post subject: Reply with quote
REDIRECT sends the traffic to the router itself. All you need to do is use the port forwarding options in the GUI.
_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
hellbound1988
DD-WRT User


Joined: 20 Apr 2009
Posts: 66

PostPosted: Tue Mar 29, 2011 15:42    Post subject: Reply with quote
tried with source net 113.231.122.0 from udp 1600 to 5060 ip address 192.168.1.5 but not working. It needs two rule to accomplish this process i guess. Because the incoming packet comes to udp redirected to 5060 udp to asterisk but the asterisk sends reply to udp 5060 that should also be redirected to udp 1600 for the specific subnet. How to to that ? I guess some firewall script lines will be helpful.

Last edited by hellbound1988 on Tue Mar 29, 2011 17:07; edited 1 time in total
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Tue Mar 29, 2011 16:32    Post subject: Reply with quote
You need to include the subnet mask in the source net field, but the GUI is currently bugged to only allow 15 characters for an IP instead of 18 for inclusion of a CIDR netmask. With smaller IP's it can still be done but you're one character too short.

You don't need to do any reverse mapping, the kernel handles it.

This set of rules is what port forwarding would do:

iptables -t nat -I PREROUTING -s 113.231.122.0/24 -d `nvram get wan_ipaddr` -p udp --dport 1600 -j DNAT --to 192.168.1.5:5060
iptables -I FORWARD -d 192.168.1.5 -p udp --dport 5060 -j ACCEPT

_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
hellbound1988
DD-WRT User


Joined: 20 Apr 2009
Posts: 66

PostPosted: Tue Apr 05, 2011 13:03    Post subject: Reply with quote
thanks for the command. I have put that command as a firewall script but its not working. How can i effectively check whether my port redirection is actually working (for myself). As i have a TP-link WR941ND i dont have ip based bandwidth management so i have a pretty long firewall script already installed & working fine.
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Tue Apr 05, 2011 17:11    Post subject: Reply with quote
Wiki: port forwarding trubleshooting
_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum