Summary:ASTERISK-00751: Netgear Router not capable of forwarding some UDP-packets
Reporter:z_smurf (z_smurf)Labels:
Date Opened:2004-01-06 19:56:37.000-0600Date Closed:2011-06-07 14:11:56
Versions:Frequency of
Description:Netgear router seems to not forward incoming packets if src-port is same as dest-port.

Assume the following configuration:
1) Asterisk on a public IP
2) Netgear rp614-v2 router on a public IP
3) Grandstream BudgeTone on a local IP behing the Netgear router.

Sip-phone local port is 5060. Netgear is forwarding WAN-port 5060 to SIP-phone correctly.
The problem apperas being the combination of asterisk and netgear. Using TCP-dump on asterisk, one can see that its outgoing packets uses the same local port as destionation port (ie 5060). Netgear does not allow this, and the packet will not reach the phone.

Replacing the Netgear with a D-link 604 solves the issue.

I have tried to solve it by changing some details in chan_sip.c.
First, we want asterisk to use the NAT-ip-adress, but the SIP-header port#.
Second, we do not want to use the already opened "sipsocket". By opening a new socket we get around the netgear-blocking-issue.


Here is my __sip_xmit function in chan_sip.c:

static int __sip_xmit(struct sip_pvt *p, char *data, int len)
       int res;
       int tmpsock;
       // Open a new fresh socket for sending.
       tmpsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
       if (p->nat)
           // The IP-adress should be same as incoming packet.
           // The port should be as described in SIP-header.
           struct sockaddr_in a;
           a = p->sa;
           a.sin_addr = p->recv.sin_addr;
           res=sendto(tmpsock, data, len, 0, (struct sockaddr *)&a, sizeof(struct sockaddr_in));
           res=sendto(tmpsock, data, len, 0, (struct sockaddr *)&p->sa, sizeof(struct sockaddr_in));
       if (res != len) {
               ast_log(LOG_WARNING, "sip_xmit of %p (len %d) to %s returned %d: %s\n", data, len, inet_ntoa(p->sa.sin_addr), res, strerror(errno));
       return res;
Comments:By: z_smurf (z_smurf) 2004-01-06 21:19:17.000-0600

Further testing on this shows that the netgear will stop forwarding ports after some time with active calls.... And Asterisk will again detect the nat-ed phones as "unavailable"....
Some time (10 seconds or more) after a call is ended, sometimes the netgear unlocks the forwarding ports... And then the grandstream phones goes crazy and sometimes freezes...

By: Brian West (bkw918) 2004-01-06 23:33:42.000-0600

This isn't an asterisk issue its that crack head grandstream phone.

By: z_smurf (z_smurf) 2004-01-07 05:39:40.000-0600

Not only grandstream but also Cisco ATA 186.
Lets say its a Netgear-issue.

By: Brian West (bkw918) 2004-01-07 08:29:37.000-0600

Strange.. must be an netgear issue but we can't rule everythingout.  I will leve this bug open for a few more days to be sure.

By: zoa (zoa) 2004-01-09 21:32:41.000-0600

looks like a netgear problem to me too.

By: Brian West (bkw918) 2004-01-09 21:41:21.000-0600

Netgear issue