IP Forwarding.

AlKwEkB
Joined: Thu 12 of Apr, 2007

IP Forwarding.

Posted:Thu 19 of Mar, 2009 (15:59 UTC)
# Asterisk Port Forwarding!.. AlKwEkB!

SIP_SRV_LAN_IP=192.168.0.140

# Puerto SIP, TCP y UDP, Just in case.
iptables -A INPUT -p udp -m udp --dport 5060 -j ACCEPT 
iptables -A INPUT -p tcp -m tcp --dport 5060 -j ACCEPT 

# RTP - the media stream
iptables -A INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT 

# FORWARDING
iptables -t nat -A PREROUTING -p udp -m multiport --dport 5060,10000:20000 -j DNAT --to-destination $SIP_SRV_LAN_IP

# ALLOW ASTERISK CONNECTIONS/REPLIES TO OUTSIDE (INTERNET)
iptables -A FORWARD -p udp -s $SIP_SRV_LAN_IP -j ACCEPT

# ALLOW FORWARDED CONNECTIONS/REPLIES TO INSIDE (LAN)
iptables -A FORWARD -p udp -m multiport --dport 5060,10000:20000 -d $SIP_SRV_LAN_IP -j ACCEPT


That is the Script on the Router.. 

This is the TCPDUMP in the Asterisk.

[root@asterisk1 asterisk]# vi sip.conf
[root@asterisk1 asterisk]# tcpdump -n -i eth0 | grep 5060
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
10:55:25.368996 IP 190.128.***.***.48117 > 192.168.0.140.5060: UDP, length 574
10:55:25.867791 IP 190.128.***.***.48117 > 192.168.0.140.5060: UDP, length 574
10:55:27.184537 IP 190.128.***.***.53018 > 192.168.0.140.5060: UDP, length 576
10:55:27.672938 IP 190.128.***.***.53018 > 192.168.0.140.5060: UDP, length 576
10:55:28.674283 IP 190.128.***.***.53018 > 192.168.0.140.5060: UDP, length 576

As you can see, i have no return.. 

[root@asterisk1 asterisk]# vi /etc/asterisk/sip_nat.conf
nat=yes
localnet=192.168.0.0/255.255.255.0
externip=190.104.***.***

//

I don't know what else you need to help me with this..
Thanks!