[asterisk-dev] Virtual IP Adresses and SIP requests failing...
Tilghman Lesher
tilghman at mail.jeffandtilghman.com
Wed Jul 4 21:12:35 CDT 2007
On Wednesday 04 July 2007, King Ho wrote:
> I think what Tilghman said is not exactly correct. That is, asterisk will
> not be able to control how the packet is routed BUT asterisk DOES have
> control of which IP address the response uses for the "source ip address"
> of the packet. That is, if I send a sip register request to asterisk at
> address x.x.x.x, I expect asterisk to response using the same x.x.x.x
> address as the
> source ip address in the response, even though asterisk won't be able to
> control how the packet is routed.
What I said was exactly how it is implemented TODAY. I should know; I wrote
the initial implementation. It has since been supplanted by MUCH better code
(and more portable, to boot).
> After some googling, I found that you can use setsockopt and IP_PKTINFO to
> get the destination address and set the source address. I found a web page
> with a complete example for a recvfromto() which will provide the
> destination address in addition to the regular stuff that recvfrom()
> provides.
As I said before, it isn't that we don't know how, it's that it hasn't been
done yet. I actually wrote sample code for Mark that does IP_PKTINFO way back
in the pre-1.0 days (2002, specifically), and it was rejected, because at the
time, he needed to know which address to send an original packet from (not
just responses). That sample code can still be found here:
http://asterisk.drunkcoder.com/hacks/udpserver.c
We ARE going to implement this, by having Asterisk bind to multiple addresses.
That is coming, with Marc's IPv6 implementation, as discussed at AstriDevCon
2007.
--
Tilghman
More information about the asterisk-dev
mailing list