traffic Forward script

Hi friends
i am living in iran. in our company , we provided 2 internet line which one of them works in national intranet and just forwards traffic to iranian websites(CALLED NATIONAL INTRANET) and another line is internet line that is known to all.
i want to divide internal requests to 2 part :
any request with .ir domain forwarded to INTRANET line and other traffic to internet.
i want to know is there any script that first define domain-suffix and then forwards it to one of the wan links in mikrotik? (first finds that typed url is .ir or no then select best way)
tnx a lot