Dial Plan allow to dial via PSTN from endpoints that are on the local network oly

I have a scenario where I have some endpoints that register from the public network. Others are meant to be registered at local headphones. The endpoints that register from public network are meant to receive the incoming calls and make calls to endpoints within the asterisk PBX but for security should not be able to call outgoing calls via PSTN. Is there a way to see in the dial plan, if the endpoint that is initiating a call has a local IP address or not and allow a call based on this?

The intended way of doing this is to put them into different contexts in the channel technology configuration file.

Otherwise, you would need to check the peer IP address against local networks, explicitly.


As was told before use different context or if you want to make this more complicated assuming is chan sip or pjsip you can use header function PJSIP_HEADER() for pjsip