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

2012-07-13 Thread Benny Amorsen
Kevin P. Fleming kpflem...@digium.com writes:

 I've just looked into this a bit, and I don't see how using connect()
 would actually solve the problem. If we receive a UDP datagram from a
 SIP endpoint, we could use socket() and connect() to create a socket
 specifically for sending to (and receiving from) that endpoint in the
 future, but we can't specify the source address to be used by that
 socket. The only way I know of to specify the source address for
 outbound packets is to use a raw socket and compose the IP header
 ourselves, which would be overkill.

You just bind() to the source address you want to use for outgoing
packets. I have just tested it, it works here at least. The tricky bit
is knowing which source address you want to use. That you can get from
IP_PKTINFO, somewhat portably.

Once you have a socket with connect() and bind(), the full 5-tuplet of
protocol, srcaddr, srcport, dstaddr, dstport is defined, and all further
traffic related to that connection should be going to that socket.
However, in between the time that the first packet arrived and that
socket is up and running, more packets may have been queued on the
original server socket. This cannot happen with TCP because accept() is
atomic (the client cannot send more data before the three-way-handshake
is done), but there is no such luck with UDP.


/Benny


--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


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

2012-07-13 Thread Benny Amorsen
Raj Mathur (राज माथुर) r...@linux-delhi.org writes:

 Precisely.  In fact, if a packet from 192.168.2.n is received on /any/ 
 interface, the response will always go out from the 192.168.2.X 
 interface.  (Barring some weird routing/iptables configuration, of 
 course.)

This is only the case for TCP, because TCP accept() fixes the whole
five-tuple of protocol, srcaddr, srcport, dstaddr, dstport. UDP does not
have an accept() equivalent and most applications just use sendto()
which lets the OS pick a source address.


/Benny


--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

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

2012-07-12 Thread Benny Amorsen
Kevin P. Fleming kpflem...@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


--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


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

2012-07-12 Thread Kevin P. Fleming

On 07/12/2012 09:19 AM, Benny Amorsen wrote:

Kevin P. Fleming kpflem...@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.


I must be missing something. If a phone sends a UDP packet to 
192.168.1.1, how does that get routed to (arrive at) the 10.0.2.1 
interface on the Asterisk server? The only way I can imagine that 
happening is if a router in between the phone and the server has been 
told that 192.168.1.0/24 is reachable *through* 10.0.2.1, which seems 
like a bizarre way to construct a network. Getting replies from Asterisk 
*back* to the phone would also require the IP stack on the Asterisk 
server to route those replies back over the 10.0.2.0/24 interface 
instead of the 192.168.1.0/24, which doesn't make any sense either.


chan_sip does have the ability to use connect()-ed sockets for dialogs 
now, since that is required for TCP, TLS and WebSocket support. It 
wouldn't be a huge leap to use them for UDP as well, if that was beneficial.


--
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
Jabber: kflem...@digium.com | SIP: kpflem...@digium.com | Skype: kpfleming
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at www.digium.com  www.asterisk.org



--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
  http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


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

2012-07-12 Thread Kevin P. Fleming

On 07/11/2012 11:36 PM, Jeff LaCoursiere wrote:


This does exhibit the problem though.  Your OS stack assumes one of
those addresses - the first identified interface? - is the one that all
replies will appear to come from.  So phones on the 192.168.2.0/24
network that try to register get replies from 192.168.1.1 and ignore
them.


No, I don't think it does. If the server has four interfaces, on subnets 
192.168.{1,2,3,4}.0/24, those are *not* overlapping, and everything will 
work as expected. If a UDP packet is received on the third interface, 
from an address reachable via routes over that interface, then the reply 
to that packet will be sent out over that same interface, with the 
source address set to the address assigned to that interface. Servers 
are setup this way all the time, and it works as it should.


There must be more to the network configuration than something this 
simple in order to cause the IP stack on the Asterisk server to choose 
the wrong source IP address for outbound packets.


--
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
Jabber: kflem...@digium.com | SIP: kpflem...@digium.com | Skype: kpfleming
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at www.digium.com  www.asterisk.org



--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
  http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


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

2012-07-12 Thread Dave Platt

 I must be missing something. If a phone sends a UDP packet to 
 192.168.1.1, how does that get routed to (arrive at) the 10.0.2.1 
 interface on the Asterisk server? The only way I can imagine that 
 happening is if a router in between the phone and the server has been 
 told that 192.168.1.0/24 is reachable *through* 10.0.2.1, which seems 
 like a bizarre way to construct a network. Getting replies from Asterisk 
 *back* to the phone would also require the IP stack on the Asterisk 
 server to route those replies back over the 10.0.2.0/24 interface 
 instead of the 192.168.1.0/24, which doesn't make any sense either.

This can and will happen, if the multi-interface Asterisk server is
also being used as the router between these networks.

In this case, the packet sent by the client system to 192.168.1.1, is
being sent by the client to the client's active (possibly default/only)
routing gateway, which will be 10.0.2.1.  The packet arrives at the
server/router, and because it matches the IP address assigned to one of
the server's network adapters (and Asterisk is bound to all of them)
it's delivered to Asterisk.

When Asterisk replies, it's doing so via a socket which is bound
to 0.0.0.0.  Since there's no specific IP address bound to this
socket, the kernel has to pick one of the host's IP addresses to
put into the packet it sends... and the one it picks is the one
assigned to the network adapter on which it chooses to transmit
the port.  In this case, that will be 10.0.2.1.

So, the client sends a packet to 192.168.1.1 and gets a response
from 10.0.2.1, which is a huge WTF situation for many protocols.

This is not just an issue for SIP.  I've had exactly this same
problem with IAX2 clients and Asterisk, and had to apply the
exact same cure - I tell IAX2 to bind itself only to my
host's externally-routable public IP address, and not to
0.0.0.0.  Then, if I specify the public IP address as the server
in each IAX2 client configuration, everything works fine.

This is probably a not-unusual configuration if you're setting up
a modest-size VoIP-only or VoIP-mostly network on a budget...
a Linux or other Unix-ish system running Asterisk will often
have enough CPU power to handle the RTP routing between networks,
saving you the cost of a dedicated router.  I have this very issue
on my own system - a modest home network with a couple of internal
LANs, some IP ranges set aside for VPNs of various sorts, and one
externally routable IP address.

 chan_sip does have the ability to use connect()-ed sockets for dialogs 
 now, since that is required for TCP, TLS and WebSocket support. It 
 wouldn't be a huge leap to use them for UDP as well, if that was beneficial.

Would be well worthwhile... and if you can port similar code over
into chan_iax2, it would fix the problem there as well.



--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


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

2012-07-12 Thread Kevin P. Fleming

On 07/12/2012 12:38 PM, Freddi Hansen wrote:


We have since Asterisk 1.2 been using a configuration with 6 NIC's
bonding to 3 networks, one public internet and 2 private networks.
Routing calls between networks and having phones on all 3 networks is no
problem.

There is one case though where we do fixup with iptables.
We have 30 virtuel adresses on one of the private networks and when
Asterisk sends a packet to a destination then the first address of the
NIC is inserted as source  by the OS.

example
one NIC has ip's
192.168.0.10,192.168.0.20,192.168.30
Telephone (192.168.0.100) sends a packet to Asterisk 192.168.0.30,
Asterisk sends response to 192.168.0.100 but with source address
192.168.0.10 as thats the first ip on that NIC.

In Iptables OUTPUT q we do a set-mark to an index into our source ip's
then in POSTROUTING we insert the source adr using the mark


Yes, this is the situation I referred to earlier. In your case, it's all 
on one interface, but the server has multiple addresses on the *same* 
network, and thus it cannot know (without help) with address should be 
used for outbound packets.


--
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
Jabber: kflem...@digium.com | SIP: kpflem...@digium.com | Skype: kpfleming
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at www.digium.com  www.asterisk.org



--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
  http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


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

2012-07-12 Thread Benny Amorsen
Kevin P. Fleming kpflem...@digium.com writes:

 I must be missing something. If a phone sends a UDP packet to
 192.168.1.1, how does that get routed to (arrive at) the 10.0.2.1
 interface on the Asterisk server?

The easiest way is that the Asterisk server itself is the router. Phones
on 10.0.2.0/24 have 10.0.2.1 as default gateway. Another option is that
there are no real routers; the phones are disconnected from the
Internet, they still have 10.0.2.1 as default gateway but they only use
it to reach the Asterisk server.

 The only way I can imagine that happening is if a router in between
 the phone and the server has been told that 192.168.1.0/24 is
 reachable *through* 10.0.2.1, which seems like a bizarre way to
 construct a network.

I do not feel that the two scenarios above are particularly bizarre.

 Getting replies from Asterisk *back* to the phone would also require
 the IP stack on the Asterisk server to route those replies back over
 the 10.0.2.0/24 interface instead of the 192.168.1.0/24, which doesn't
 make any sense either.

If the phone is on 10.0.2.0/24, the IP stack will route packets to it
directly through the 10.0.2.1-interface by default. It actually takes
quite serious contortions to make it send the packets elsewhere.

Servers with multiple interfaces are a bit out of the ordinary. Right
now Asterisk is difficult to work with on such servers, which is not a
large problem for Asterisk in general, because they are so rare. You can
always work around the problem either by creative routing or by
explicitly binding to one address.

 chan_sip does have the ability to use connect()-ed sockets for dialogs
 now, since that is required for TCP, TLS and WebSocket support. It
 wouldn't be a huge leap to use them for UDP as well, if that was
 beneficial.

It would be greatly appreciated :) It is low priority for the Asterisk
project, as there are always workarounds.

Extra points for making Asterisk support IP addresses appearing and
disappearing... That would make VRRP/HSRP failover work. (It works if
you bind to 0.0.0.0, but it is difficult to get Asterisk to use the
VRRP-address as the source address for outgoing packets).


/Benny

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


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

2012-07-12 Thread Kevin P. Fleming

On 07/12/2012 03:53 PM, Benny Amorsen wrote:


chan_sip does have the ability to use connect()-ed sockets for dialogs
now, since that is required for TCP, TLS and WebSocket support. It
wouldn't be a huge leap to use them for UDP as well, if that was
beneficial.


It would be greatly appreciated :) It is low priority for the Asterisk
project, as there are always workarounds.


I've just looked into this a bit, and I don't see how using connect() 
would actually solve the problem. If we receive a UDP datagram from a 
SIP endpoint, we could use socket() and connect() to create a socket 
specifically for sending to (and receiving from) that endpoint in the 
future, but we can't specify the source address to be used by that 
socket. The only way I know of to specify the source address for 
outbound packets is to use a raw socket and compose the IP header 
ourselves, which would be overkill.


Benny, are you aware of some other method to accomplish this?

--
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
Jabber: kflem...@digium.com | SIP: kpflem...@digium.com | Skype: kpfleming
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at www.digium.com  www.asterisk.org



--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
  http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


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

2012-07-12 Thread Raj Mathur (राज माथुर)
On Thursday 12 Jul 2012, Kevin P. Fleming wrote:
 On 07/11/2012 11:36 PM, Jeff LaCoursiere wrote:
  This does exhibit the problem though.  Your OS stack assumes one of
  those addresses - the first identified interface? - is the one that
  all replies will appear to come from.  So phones on the
  192.168.2.0/24 network that try to register get replies from
  192.168.1.1 and ignore them.
 
 No, I don't think it does. If the server has four interfaces, on
 subnets 192.168.{1,2,3,4}.0/24, those are *not* overlapping, and
 everything will work as expected. If a UDP packet is received on the
 third interface, from an address reachable via routes over that
 interface, then the reply to that packet will be sent out over that
 same interface, with the source address set to the address assigned
 to that interface. Servers are setup this way all the time, and it
 works as it should.

Precisely.  In fact, if a packet from 192.168.2.n is received on /any/ 
interface, the response will always go out from the 192.168.2.X 
interface.  (Barring some weird routing/iptables configuration, of 
course.)

 There must be more to the network configuration than something this
 simple in order to cause the IP stack on the Asterisk server to
 choose the wrong source IP address for outbound packets.

I've usually seen this (wrong interface chosen for outbound) happen when 
NAT is in the picture.  However, the OP doesn't mention any NAT-related 
configuration.

Regards,

-- Raj
-- 
Raj Mathur  || r...@kandalaya.org   || GPG:
http://otheronepercent.blogspot.com || http://kandalaya.org || CC68
It is the mind that moves   || http://schizoid.in   || D17F

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


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

2012-07-11 Thread Kevin P. Fleming

On 07/11/2012 07:51 AM, Olle E. Johansson wrote:


10 jul 2012 kl. 20:50 skrev Kevin P. Fleming:


On 07/10/2012 03:24 AM, Olle E. Johansson wrote:


The Asterisk SIP channel has no knowledge about interfaces and can't
bind to a specific interface for communication. In fact, it's a well known
bug that if you have multiple interfaces with different IP networks,
Asterisk will send from the wrong IP on some of the interfaces.


Are you sure about that? The only problem area that I'm aware of is when there 
are multiple *overlapping* interfaces (on the same subnet, or providing the 
same route(s)). In that case, Asterisk can receive messages on one IP address 
out of the overlapping set, but reply using a different one from the set, 
because it doesn't specify the source IP address and instead lets the UDP/IP 
stack select one.

If the interfaces don't overlap in any way, I don't see how it would be 
possible for Asterisk to send messages with the wrong source IP address, since 
it does not specify the source IP address at all. If this is occurring, it must 
involve the operating system's IP stack in some fashion.


Yes, I still use quite a lot of IPtables tricks to overcome this issue.


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

--
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
Jabber: kflem...@digium.com | SIP: kpflem...@digium.com | Skype: kpfleming
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at www.digium.com  www.asterisk.org



--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
  http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


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

2012-07-11 Thread Alec Davis
I've seen similar.

We tried 4 interfaces. On 4 lans, are these considered to be overlapping?
192.168.1.1
192.168.2.1
192.168.3.1
192.168.4.1

I tried this months ago on 1.8, and set provisioned phones to register with
asterisk interface on the lan they were on.
The phones won't register, we're un-responsive, 60 of them.

Removed the bindings, and left only one.
Reprovisioned the phones again, all 60 of them. All is well.

Have I tried again. No.
Did I have enough time to debug. No.
Sorry.

Alec Davis
 

 -Original Message-
 From: asterisk-users-boun...@lists.digium.com 
 [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of 
 Kevin P. Fleming
 Sent: Thursday, 12 July 2012 2:28 a.m.
 To: asterisk-users@lists.digium.com
 Subject: Re: [asterisk-users] chan_sip sending from wrong 
 source address when multiple interfaces are used
 
 On 07/11/2012 07:51 AM, Olle E. Johansson wrote:
 
  10 jul 2012 kl. 20:50 skrev Kevin P. Fleming:
 
  On 07/10/2012 03:24 AM, Olle E. Johansson wrote:
 
  The Asterisk SIP channel has no knowledge about 
 interfaces and can't 
  bind to a specific interface for communication. In fact, 
 it's a well 
  known bug that if you have multiple interfaces with different IP 
  networks, Asterisk will send from the wrong IP on some of 
 the interfaces.
 
  Are you sure about that? The only problem area that I'm 
 aware of is when there are multiple *overlapping* interfaces 
 (on the same subnet, or providing the same route(s)). In that 
 case, Asterisk can receive messages on one IP address out of 
 the overlapping set, but reply using a different one from the 
 set, because it doesn't specify the source IP address and 
 instead lets the UDP/IP stack select one.
 
  If the interfaces don't overlap in any way, I don't see 
 how it would be possible for Asterisk to send messages with 
 the wrong source IP address, since it does not specify the 
 source IP address at all. If this is occurring, it must 
 involve the operating system's IP stack in some fashion.
 
  Yes, I still use quite a lot of IPtables tricks to overcome 
 this issue.
 
 That's quite interesting; can you describe a scenario where 
 this occurs?
 
 --
 Kevin P. Fleming
 Digium, Inc. | Director of Software Technologies
 Jabber: kflem...@digium.com | SIP: kpflem...@digium.com | 
 Skype: kpfleming
 445 Jan Davis Drive NW - Huntsville, AL 35806 - USA Check us 
 out at www.digium.com  www.asterisk.org
 
 
 
 --
 _
 -- Bandwidth and Colocation Provided by http://www.api-digital.com --
 New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
 
 asterisk-users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users


--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


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

2012-07-11 Thread Jeff LaCoursiere
On Thu, 2012-07-12 at 15:49 +1200, Alec Davis wrote:
 I've seen similar.
 
 We tried 4 interfaces. On 4 lans, are these considered to be overlapping?
 192.168.1.1
 192.168.2.1
 192.168.3.1
 192.168.4.1
 

Depends on the netmask you use :)  Assuming you used /24, so no, they
don't overlap.

This does exhibit the problem though.  Your OS stack assumes one of
those addresses - the first identified interface? - is the one that all
replies will appear to come from.  So phones on the 192.168.2.0/24
network that try to register get replies from 192.168.1.1 and ignore
them.


j

 I tried this months ago on 1.8, and set provisioned phones to register with
 asterisk interface on the lan they were on.
 The phones won't register, we're un-responsive, 60 of them.
 
 Removed the bindings, and left only one.
 Reprovisioned the phones again, all 60 of them. All is well.
 
 Have I tried again. No.
 Did I have enough time to debug. No.
 Sorry.
 
 Alec Davis
  
 
  -Original Message-
  From: asterisk-users-boun...@lists.digium.com 
  [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of 
  Kevin P. Fleming
  Sent: Thursday, 12 July 2012 2:28 a.m.
  To: asterisk-users@lists.digium.com
  Subject: Re: [asterisk-users] chan_sip sending from wrong 
  source address when multiple interfaces are used
  
  On 07/11/2012 07:51 AM, Olle E. Johansson wrote:
  
   10 jul 2012 kl. 20:50 skrev Kevin P. Fleming:
  
   On 07/10/2012 03:24 AM, Olle E. Johansson wrote:
  
   The Asterisk SIP channel has no knowledge about 
  interfaces and can't 
   bind to a specific interface for communication. In fact, 
  it's a well 
   known bug that if you have multiple interfaces with different IP 
   networks, Asterisk will send from the wrong IP on some of 
  the interfaces.
  
   Are you sure about that? The only problem area that I'm 
  aware of is when there are multiple *overlapping* interfaces 
  (on the same subnet, or providing the same route(s)). In that 
  case, Asterisk can receive messages on one IP address out of 
  the overlapping set, but reply using a different one from the 
  set, because it doesn't specify the source IP address and 
  instead lets the UDP/IP stack select one.
  
   If the interfaces don't overlap in any way, I don't see 
  how it would be possible for Asterisk to send messages with 
  the wrong source IP address, since it does not specify the 
  source IP address at all. If this is occurring, it must 
  involve the operating system's IP stack in some fashion.
  
   Yes, I still use quite a lot of IPtables tricks to overcome 
  this issue.
  
  That's quite interesting; can you describe a scenario where 
  this occurs?
  
  --
  Kevin P. Fleming
  Digium, Inc. | Director of Software Technologies
  Jabber: kflem...@digium.com | SIP: kpflem...@digium.com | 
  Skype: kpfleming
  445 Jan Davis Drive NW - Huntsville, AL 35806 - USA Check us 
  out at www.digium.com  www.asterisk.org
  
  
  
  --
  _
  -- Bandwidth and Colocation Provided by http://www.api-digital.com --
  New to Asterisk? Join us for a live introductory webinar every Thurs:
 http://www.asterisk.org/hello
  
  asterisk-users mailing list
  To UNSUBSCRIBE or update options visit:
 http://lists.digium.com/mailman/listinfo/asterisk-users
 
 
 --
 _
 -- Bandwidth and Colocation Provided by http://www.api-digital.com --
 New to Asterisk? Join us for a live introductory webinar every Thurs:
http://www.asterisk.org/hello
 
 asterisk-users mailing list
 To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users



--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


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

2012-07-11 Thread Duncan Turnbull
Similar problem
On 12/07/2012, at 4:36 PM, Jeff LaCoursiere wrote:

 On Thu, 2012-07-12 at 15:49 +1200, Alec Davis wrote:
 I've seen similar.
 
 We tried 4 interfaces. On 4 lans, are these considered to be overlapping?
 192.168.1.1
 192.168.2.1
 192.168.3.1
 192.168.4.1
 
 
Running openvpn on asterisk server for a few remote users.

 Depends on the netmask you use :)  Assuming you used /24, so no, they
 don't overlap.
 
 This does exhibit the problem though.  Your OS stack assumes one of
 those addresses - the first identified interface? - is the one that all
 replies will appear to come from.  So phones on the 192.168.2.0/24
 network that try to register get replies from 192.168.1.1 and ignore
 them.
 
The normal LAN phones get replied to using the standard LAN address, the ones 
over openvpn get a reply using the local openvpn address, which if they aren't 
expecting it they ignore

We got round it by setting the outbound proxy to the unexpected address and 
then everything seems happy - we are using Yealink though so it maybe different 
for other phones

You could use IP Tables I guess too

Cheers Duncan
--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users