Block registrations

I have an asterisk server to act as a backup voip server.

I need to be able to block registration attempts, but still allow invite attempts. I don’t want people to ever register to the system since it should only be used in the event the other one is down, but I want the phones to still send invites to it.

I can already send invites to it and it works, but sometimes my phone will start to register with it (and fail with ‘not found’). Once it starts to register, it will continue to register forever until I kill the daemon.

There has to be a way to do this, however I can’t find any solutions online.

Any ideas?

I don’t think there really is a solution. Think about what you are trying to do. You are telling the server to be selective on what it looks at and what it doesn’t look at. I think you would need to patch asterisk for this. Do you need the invites to come to the server when it is in back up mode ? I would use hearbeat with your current solution so the IP only starts working when it is needed.

I found a way to do it by modifying the source code.

asterisk-1.4.14/channels/chan_sip.c

Changed:

                    } else {
                            /* URI not found */
                            if (res == AUTH_PEER_NOT_DYNAMIC)
                                    transmit_response(p, "403 Forbidden", &p->initreq);
                            else
                                    transmit_response(p, "404 Not found", &p->initreq);
                    }

To:

                    } else {
                            /* URI not found */
                            if (res == AUTH_PEER_NOT_DYNAMIC)        
                                    transmit_response(p, "403 Forbidden", &p->initreq);
                    }

Asterisk was giving out a ‘404 not found’ based on all registrations, so I removed the line and now it doesn’t reply at all, and therefore phones think it’s unavailable and don’t try to register.

Then what is the point in the server ? Don’t you want it to accept registrations if the main server fails ? How does it know when to start accepting registrations ?