Get IP address of the IP phones using PHP script

Hi friends,

I’m developing a web system to make calls from hard phones. Call must dial when clicked on the call button on the web system. To dial a call I want to find the IP address of the hard phone. If i can get the IP address of the hard phone then I can directly connect with it. I already have the extensions of the users. Is it possible to get user’s IP address from the asterisk passing the user extension using PHP?

Even assuming a VoIP environment, Asterisk extensions do not necessarily have an IP address at all (e.g. voice response), or may an indeterminate address (queues, hunt group, & notation in dial strings).

Although I would have to checek the details, you should be able to get the registered or static IP of SIP peer, using AMI, but this will be based on the peer name, which need not match any extension name.

1 Like

I forgot to say that, with PJSIP, you can have multiple addresses, even at this level.

From the looks of it, the function to do an AMI read variable on would be PJSIP_DIAL_CONTACTS(). You would need to parse the result, and it is possible that it returns uninterpreted domain names, if that was what was in the Contact header, on the REGISTER.

1 Like

using chan_sip you can use sip show peer command also on pjsip use pjsip show contact

1 Like

Thank you very much @david551
I’ll try it

Thank you very much @ambiorixg12

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.