Postman Pat <a…@the-post-office-not.com> wrote:
> Thank you :) > > I enabled SIP ALG, so that is in addition to 5060 forwarding to the > phone's internal LAN IP (which is also fixed in the phone config) and > the phone rings OK now. > > I still fail to see how SIP ALG *alone* can forward 5060 on incoming > calls while allowing in only A&A IPs. This is a Draytek router without > any remote or internal ("plug and play crap") config.
Roughly speaking, although it may differ from vendor to vendor (and may do other stuff in addition): 1. Phone on LAN makes outgoing connection to SIP server port 5060, saying it is available on RTP port range aaaa-bbbb. 2. NAT rewrites the IP on the packet headers from phone's LAN IP to public IP, creates an entry in the NAT table to remember the state of this connection for its duration. (this is what NAT does for every connection) 3. SIP ALG rewrites the IP address inside the SIP connection to be the public IP, not the LAN IP 4. SIP ALG creates a temporary firewall rule to forward incoming RTP traffic from the SIP server's source IP to the phone's LAN IP, based on the ports described in the SIP connection 5. Incoming audio: SIP server opens an RTP connection to the router in the appropriate port range, using the same source IP as the initial SIP connection. 6. Using the temporary firewall rule, router forwards RTP traffic to the phone's LAN IP 7. Phone receives and sends audio 8. <phone call happens> 9. Phone deregisters by closing SIP connection (perhaps it was turned off) 10. Server closes RTP connection 10. NAT drops NAT table entries for connections 11. SIP ALG deletes temporary firewall rule Any point from 4 onwards if an attacker tries to connect, their source IP will not match the source IP in the temporary firewall rule and their connection will be blocked. Before point 4 they would be blocked by default. A key issue here is the temporary firewall rule in step 4 only works if this SIP server is talking to a single SIP endpoint on the LAN. If you have multiple SIP clients on the LAN then the firewall sees an incoming connection and has no means to identify which SIP client it is for, resulting in one way audio and/or no rings. That problem is solved by IPv6, but it's also solved by setting the RTP ports in each client to be different. That way the firewall knows that RTP to ports aaaa-bbbb goes to client 1 and cccc-dddd goes to client 2, ie you end up with two temporary firewall rules. (a separate one-way calling issue is clients on mobiles going to sleep and not being ready to receive the connection when a call is incoming, but that's not relevant here)
> If I get any more hassle I will move the whole lot to Voipfone. > Simpler and non-arrogant... I am with them at another location and > have had zero downtime in 3 years (fibre + Grandstream VOIP).
I've had zero downtime with A&A VOIP in ~10 years... aside from the internet connection which they don't control. TBH, given how much of a hack the above is and the weird stuff the router vendor could be doing, which is impossible to packet-capture if it's also your DSL modem in the same ISP-locked-down box, I'm not surprised they would much rather you use IPv6 and have a limited time to debug IPv4 problems. I think a lot of it would also be solved if you're running the SIP client on the router, ie with a public IPv4, like most ISP boxes are running their own VOIP. Then you aren't putting it behind NAT and it all works sensibly. So a router with maybe a DECT base and an analogue socket avoids a lot of NAT issues, ie VOIP is never going over the LAN. That said, I've used A&A with Gigaset boxes behind numerous ISPs and it's 'just worked'; the most I've had to do is turn on the SIP ALG setting in the ISP router. Theo