[asterisk-users] chan_sip sending from wrong source address when multiple interfaces are used

Benny Amorsen benny+usenet at amorsen.dk
Thu Jul 12 09:19:50 CDT 2012


"Kevin P. Fleming" <kpfleming at digium.com> writes:

> That's quite interesting; can you describe a scenario where this occurs?

Imagine you have a server with two interfaces, eth0 with 192.168.1.1/24
and eth1 with 10.0.2.1/24. Further imagine that you wish to be able to
move phones between the networks without changing the SIP server
address, so you set 192.168.1.1 as the SIP server no matter which
network they happen to be on.

Now the phones which happen to be connected to eth1 will send a request
to 192.168.1.1. If Asterisk is bound to 0.0.0.0, the reply will come
from 10.0.2.1. This could be solved if Asterisk did a connect() to the
socket and use the same socket for answering. That would tell the system
IP stack that this is in fact a connection, and so the system would
ensure that the reply source IP would be correct.

Alas, few programmers are aware that you can even do connect() for UDP,
and I believe it would be a rather large change to the Asterisk SIP
stack to pass connected sockets around rather than just remembering IP
addresses and port numbers. (Admittedly I haven't looked at that code in
ages, so I could easily be wrong).

The workaround is to explicitly bind to 192.168.1.1. Since Asterisk can
bind to precisely one address, that kills off IPv6.


/Benny




More information about the asterisk-users mailing list