Templates are not consistently working with static IP

I am trying to create a new template with a router and VM in it. I have installed contextualization in the Ubuntu VM. And the template assigns static IP to both router and VM. But when I try to xRDP to the VM, it is not consistent. For 2 out of 5 times it works with same script.

Why is it so inconsistent?