As explained in the article
Create or modify an unassigned number range in Skype for Business Server 2015
"Skype for Business Server enables you to say what happens to incoming calls to phone numbers that are valid for your organization, but are not assigned to a user or a phone. To handle such calls, you set up an unassigned number table. You can use the table to route the calls to an Announcement application."
That is nice as a service to people dialing a wrong number, but the unassigned numbers feature can also be used to prevent loops as described in the article
How to prevent call looping between Lync Server and a VoIP gateway
Since loops in telecom systems never are a good thing, let's look at how to configure the unassigned numbers feature. The first step is to record the announcement you would like to play when an unassigned number is called. I used the free Audacity software for this, and then I exported the audio as a WMA version 2 FFmpeg file.
My message were something like:
"Welcome to <our org name>, you have called a number that is not in use.
Please check the number and call again."
Next get on your Skype4B standard or enterprise front-end server and start the Skype4B management shell to import and configure the announcement.
Get-Content "C:\temp\UnassignedAnnouncement.wma" -ReadCount 0 -Encoding Byte | Import-CsAnnouncementFile -Parent ApplicationServer:skype4b.kressmark.com -FileName "UnassignedAnnouncement.wma"
New-CsAnnouncement -Identity ApplicationServer:skype4b.kressmark.com -Name “Unassigned Announcement” -AudioFilePrompt “UnassignedAnnouncement.wma”
The last command will give you an output like this:
Name : Unassigned Announcement
AudioFilePrompt : UnassignedAnnouncement.wma
AnnouncementId : d5b4b757-df0a-494a-af52-0531f6f12b2d
Now open the Skype4B Control Panel (or restart it if you had it open already.)
Go to Voice Features / Unassigned numbers to configure the range of numbers that should be homed (accessed over the SIP Trunk) on the Skype4B system.
Please note that you could enter the number with a + sign but without a leading tel: so it is a bit different from other places in the Skype4B Control Panel. The help file says "This means the number may begin with the string tel: (if you don’t specify that string, it will be automatically added for you), a plus sign (+), and a digit 1 through 9." (But why is not tel: added automatically when assigning a number to a user?)
The unassigned number table can include both assigned and unassigned numbers, but it is invoked only when a caller dials a number that is not currently assigned. This means it is fine to add one of the numbers in the range to a user and a call to that number will go to the user, or the other way around, if you remove a number in the range from a user a call to that number will get the announcement.
After committing these changes you do not need to restart anything, simply grab an internal client with a user with enterprise voice and dial one of the numbers in the range. You should now hear the message you recorded, and on the server you should also find event 46041 from LS Outbound Routing which says "Vacant Number Settings Loaded Successfully".
Next up would be to test an unassigned number from an external telephone.
If this call does not reach the announcement service chances are that you have configured a PSTN usage for the trunk under Voice Routing / Trunk Configuration in the Control Panel. This PSTN usage will somehow take precedence over the internal announcement service and will not let calls through. Remove the PSTN usage from the Trunk Configuration and your external call should be hearing the announcement now, and you will not risk getting loops in your system.
For more info:
Redirecting inbound PSTN calls in Lync
PSTN to Lync 2013 Unassigned Number failure