I have a router with three "subnets": one is private (192.168.20.0/24), the other is the Internet, and the third is an IPSEC route (192.168.21.0/24).
Sip1
^
|192.168.20.2
|
|192.168.20.1
v
Router <------------------------------> Sip2
192.168.21.44 192.168.21.1
^
|134.123.143.213
|
|242.241.224.214
v
Sip3
I want Sip1 to be able to call and be called by Sip2 as well as Sip3. Sip1 neither has a public address nor an address in the 192.168.21.0/24. The router does NAT on 192.168.21.44 and 134.123.143.213.
Siproxd doesn't work well in this scenario because it has the incoming and outgoing interfaces defined globally, and it tries to figure out the IP addresses from that. This is dubious because interfaces can have multiple addresses, and the interfaces don't matter to siproxd except for this hack.
Instead, siproxd should consult the routing table, separately for each registration or destination address. (Overriding the outgoing interface's address in special cases is still fine of course.)
Any thoughts?
I'm attaching a function for looking up the outgoing address the kernel would use for a particular destination address via rtnetlink. This is basically what ``ip route get ...'' does.
(IIRC it is somehow possible to find out the outgoing address from a socket once it is connected, but siproxd doesn't really do that. This may be a little less code, but I can't find where this was discussed before.)
Logged In: YES
user_id=438614
Originator: NO
I'll have a look at it.
A workaround is to have one siproxd instance running for each NAT traversal (using an external REGISTRAR).
Query outgoing interface address and local addresses
Logged In: YES
user_id=29868
Originator: YES
Here is an improved version which also includes a function for determining all a host's local addresses. This can easily be used for replacing if_inbound. (Tested on i386, x86_64, ppc64, mips.)
File Added: netlink-query.c