Relay Postfix

Hi everyone, I have a smtp relay configured in but it sends all emails through the relay. How can you make it only send emails through the relay when the domain is not within the same machine? domains on the same machine with shared ip be sent normal, without using the relay. Thank you.