Help Custom Routing depending on source


I am new to asterisk and FreePBX, I just installed Asterisk 11 with freepbx (using the current distro) and I also installed the bare asterisk 11 so I can learn. In our infrastructure we have DID numbers. What we are looking for is to route the call to another extension if no one picks up or busy only if the call to the DID number is coming from the “world” also if a call is placed within the LAN to the same DID number and it is busy or unavailable then route the call to the user’s Voicemail if they have one.

So for example, how do I route a call coming to DID number 12345678 to extension 2222 if “12345678” is busy or unavailable and also if extension 3333 calls the DID number “12345678” or calls another extension “5678” how do I route the call to the extension’s voice mail if they did not pick?

How best can I achieve this? Thanks in advance for your help.

Sys. Admin