Asterisk on an interface with a secondary IP

Hello everyone

I have asterisk listening on an interface which has a secondary ip


Sometimes when an external sip device tries to register, asterisk would respond as and in other cases as Is there any way to control this behavior? I mean, can I specify what IP address asterisk has to use responding?

Thanks and best regards

What is your default route that is set on the Linux server that is running Asterisk?

My default route is (the real public IP is different)

That is strange. In my experience, if the default route it set to eth0:1 (with public IP address), Asterisk always uses the public IP address (eth0:1) for communicating with the clients that are communicating with it via the internet/eth0:1 connection.

What version of Asterisk are you using?

Can you do a “sip set debug on” when the problem happens and copy/paste the output here?

Asterisk not work on network Layer 3. Packets ALWAYS routed by kernel.

Yes, but Asterisk needs to include the correct IP address in the From and Contact headers. And that address depends on the routing table.

I don’t think Asterisk will read the routing table directly. I think it still relies on the kernel handling of the situation.

Majority of Asterisk servers that I manage have 2 NIC. The reason for that is that almost very TSP in Slovenia is not offering SIP Trunking via Internet, but instead they offer their services via a private VoIP network to which Asterisk needs to be connected directly. So this is an example of my Asterisk server NIC setup:

ETH0 - (private LAN where all the local SIP phones are connected to)
ETH1 - (private VoIP network from the TSP, SIP Trunk is accessible only via this network)

The only thing I need to set is Linux routing table and the NIC configuration files. For communication with local SIP phones Asterisk uses it’s ETH0 IP address, for communication with TSP Asterisk uses it’s ETH1 IP address. How it does that I do not know. I just know it does :wink: