Re: PJSUA with two NICs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

you have to bind the specific IP address to the specific interface:

https://www.pjsip.org/pjsip/docs/html/structpjsua__transport__config.htm#a672e097722cbc1d4308d1bcd7bb4d911


Best regards

Franz


Von: pjsip <pjsip-bounces@xxxxxxxxxxxxxxx> im Auftrag von Bui Quy <quybd@xxxxxxxxxxxx>
Gesendet: Freitag, 21. Februar 2020 11:13
An: pjsip@xxxxxxxxxxxxxxx
Betreff: PJSUA with two NICs
 
Hi,

I would like to set up a system like below:

               (172.36.100.11)                             (172.36.100.12)
               enp1s0 ----------------------------------- enp1s0
PC 1 ------ |                                                        |------------ PC 2
               enp2s0 ----------------------------------- enp2s0
               (172.36.101.11)                             (172.36.101.12)

I can make a call from PC1 to PC2 via enp2s0 interface (172.36.101.11), but all the RTP packets are always going through enp1s0 (172.36.100.11) not enp2s0 (172.36.101.11).
How can I make those RTP packets go through the enp2s0 interface?

I follow this site to config two default gateway:
https://www.thomas-krenn.com/en/wiki/Two_Default_Gateways_on_One_System

On PC1:
route -n
Destination     Gateway         Genmask          Flags   Metric  Ref    Use   Iface
0.0.0.0             172.36.100.1    0.0.0.0               UG    0         0        0       enp1s0
169.254.0.0     0.0.0.0              255.255.0.0       U       1000   0        0       enp1s0
172.36.100.0   0.0.0.0              255.255.255.0   U       0         0        0       enp1s0
172.36.101.0    0.0.0.0             255.255.255.0   U       0         0        0       enp2s0

ip route list table rt2
default via 172.36.101.1 dev enp2s0
172.36.101.0/24 dev enp2s0  scope link  src 172.36.101.12

ip rule show
0: from all lookup local
32764: from all to 172.36.101.12/24 lookup rt2
32765: from 172.36.101.12/24 lookup rt2
32766: from all lookup main
32767: from all lookup default

When I make a call from PC1 to PC2 via enp2s0, this is the INVITE message:

Internet Protocol Version 4, Src: 172.36.101.11, Dst: 172.36.101.12
User Datagram Protocol, Src Port: 4321, Dst Port: 1234
Session Initiation Protocol (INVITE)
    Request-Line: INVITE sip:172.36.101.12:1234 SIP/2.0
    Message Header
        Via: SIP/2.0/UDP 172.36.100.11:4321;rport;branch=z9hG4bKPjXPf3YS3e4e6gZ0m4z.oDyeO0KNHwknAE
        Max-Forwards: 70
        From: <sip:172.36.100.11>;tag=Fd18S4-WSwPB3bxA7.QstNy.GomS4lSO
        To: sip:172.36.101.246
        Contact: <sip:172.36.101.11:4321;ob>
        Call-ID: MTqhGS7DmAfQxEvZSlH9gpf3be.UycnQ
        [Generated Call-ID: MTqhGS7DmAfQxEvZSlH9gpf3be.UycnQ]
        CSeq: 16789 INVITE
        Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
        Supported: replaces, 100rel, timer, norefersub
        Session-Expires: 1800
        Min-SE: 90
        Content-Type: application/sdp
        Content-Length:   476
    Message Body

As you can observe, my enp1s0 address (172.36.100.11) is in the Via and From headers.
I can force those headers to use enp2s0 address (172.36.101.11) by adding this line at the end of pj_gethostip() function:
PJ_DEF(pj_status_t) pj_gethostip(int af, pj_sockaddr *addr)
{
   ....
   ....
   pj_sockaddr_copy_addr(addr, &cand_addr[selected_cand]);
    TRACE_((THIS_FILE, "Candidate %s selected",
        pj_sockaddr_print(addr, strip, sizeof(strip), 0)));
    }

    addr->ipv4.sin_addr.s_addr = inet_addr("172.36.101.11");
    return PJ_SUCCESS;
}
But even after that, all the RTP packets still going through enp1s0.

Any advice would be most welcome!

Best Regards,
===============================================================
Quy Bui Danh (Mr.)

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux