You need to decide which is going to be the master and what is going to be the slave. Let us assume Sonar is master and drum machine is slaving.
You need to connect only one midi lead from the midi OUT on your interface to the midi IN jack of the drum machine.
You need to tell Sonar to transmit a midi clock out that very port you are connecting to. You need to let the drum machine know to sync to incoming midi clock as well. (p45 of the Alesis manual)
Starting Sonar should clock the drum machine. Now about the count-in that could be normal in that Sonar could start transmitting the midi clock straight away. It is quite common to do that.
As long as you don't have any midi OUT from the drum machine back to your midi interface you will not get a midi feedback loop.
Another option is to make the drum machine the master and Sonar the slave but I would not recommend it as your tempo settings would have to come from the drum machine rather than internally from Sonar. And you would have to operate the drum machine all the time to make Sonar work. But if you are just transferring loops or grooves and things that could be an option.
(but you will need to send midi clocks from the Alesis and put Sonar into slave mode or lock to incoming clock) If by chance you do have two midi leads connected (ie both directions) between drum machine and Sonar then you need to tell the Alesis NOT to echo the Midi IN signal out the midi OUT jack (p46 of manual ie Midi Thru OFF) Also you need to tell the Alesis NOT to send any midi clock signals as well. (p45 of manual) This could be sending Sonar into a tiz as well.