Call not sending when host = dynamic rather than gateway IP

I am facing issue in calling by gateway when host = dynamic rather than gateway IP in sip.conf

localhost*CLI> channel originate sip/9001/9610730117 extension 999@abc
== Using SIP RTP CoS mark 5
– Got SIP response 503 “Service Unavailable” back from 192.168.43.15:5060

Insufficient information. Just for a start, where does 192.168.43.15 fit into your network, but htat is not the only configuration information we need.

this is full configuration
it works when I put gateway IP rather than dynamic
[9001]
username = 9001
secret =
host = dynamic
type = peer
disallow = all
allow = ulaw;alaw
context = every-incoming
fromuser = 9001
fromdomain = dynamic
dtmfmode = rfc2833
defaultip =
senderpid =
trusterpid =
canreinvite =
rfc2833compensate =
monitor =
rtpupdate =
insecure =
tos =
userephone =
dialcode = 2***
prefix = 2
nat = yes
;80031234

The peer type doesn’t expect registrations and expects to know the host it is peering with. If the host is going to be dynamic then you need to use registrations to tell Asterisk where the location of the peer is. You also need to set type=friend for registrations/dynamic hosts.

Why is this set to just “dynamic”?

I have installed 3cx on laptop and when register any channel then its connect if host / fromdomain = dynamic.

so I can call directly by sim.

This is untrue and against best practice. Other options should only be used if there are multiple devices with the same IP address or the source address for inbound calls differs from the destination (very rare for dynamic cases).

It is a not uncommon cause of misoperation when the system includes tie trunks between multiple sites .

In any case it only affects incoming calls and the OP is saying htat outgoing ones are the ones that are failing.

I’m still awaiting an explanation of the significance of 192.168.43.15.

192.168.43.1 this is my router IP

If the router is on a private address, presumably the peer is not, in which case you need to configure for operation behind NAT, with options like externip and localnet. If your configuration is more complex than this, you need to provide a lot of details.

You should also disable SIP client functions in the router, as they seem to be adding to the confusion, and any SIP Application Layer Gateway function.

The address that gets registered should be the actual address of the peer, or, its “public” address, not the address of the outbound router private address. Having the outbound router address could only really happen if router or peer is misconfigured.

Note that the yes parameter of nat= is deprecated, as is the canrenvite name for directmedia. The options set by nat= are mainly for cases where Asterisk is outside the NAT boundary, and the peer is inside. It is often possible to have Asterisk inside NAT with the default values of nat=.

OK, yes a peer can do registration but really why? type=peer uses the IP/port to auth the calls and doesn’t care about the user/password. So the question becomes is this gateway on static IP because if it is then there is no need for host=dynamic it should be the actual IP of the gateway. You should only being using host=dynamic when you don’t know what the IP/port is going to be (due to the device having a dynamic IP)

Nothing that has been shown so far by the OP has any reference to this IP address. The 503 came back from 192.168.43.15 which means with type=peer and host=dynamic in order for Asterisk to send that call to 192.168.43.15 the device registered and gave that IP as its location. Since the device is returning a 503 that means the call hit it and it denied it for whatever reason.

So I guess the questions that need to be ask of @gpsbaroli are:

  1. Are Asterisk and the Gateway on the same network? They are both on 192.168.43.x?
  2. Does the gateway have a static IP assigned to it?
  3. Does the gateway REGISTER to Asterisk and does it show up under “sip show peers” with an IP?

type=peer does not stop the secret being checked; that’s why insecure=invite becomes so much a part of recipe based configurations. In fact the typical failure with tie trunks is that you have a trunk that is authenticated by IP address, not secret, the caller ID is the same as the address of a local dynamic peer, and the call fails because Asterisk triest to authenticate the call based on the type=user (friend) match on the caller ID, rather than the IP address of the other side of the trunk.

From a security point of view, type=friend means that an attacker can attempt to find the password without breaking an existing registration, so a legitimate user will not notice that anything is wrong.

I missed out the final five in a cut and paste error, when making the second request for an explanation of the address. Assumptions about the router are wrong, but we still need to know what …15 is.

If it is some sort of PSTN gateway, you need to look at the Contact header in the register request it sent. Asterisk should be sending the outgoing requests to that address. Also you need to look at its logs, as it is much more likely to know whey it rejected the request than Asterisk is.

Asterisk system IP : 192.168.43.192
Gateway IP : 192.168.43.15

Both have local IP not static IP

I have installed asterisk but when I run
channel originate sip/9001/6350323493 extension 999@abc
I get

No such command ‘channel originate sip/9001/6350323493 extension 999@abc’

A static IP means that the IP is not being dynamically assigned via DHCP. Doesn’t matter if it’s programmed in the device or a static leased based on the device MAC. That has nothing to do with local or public.

I have not set IP but its fixed automatically

Do I need to assign IP to system rather than ontain automatically?

Most routers will allow you to set static addresses which are assigned using DHCP.

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