Hi @Evi Venizelou ,
In order to better help you, I want to confirm with you that whether all the mailboxes are in Exchange online? If so, based on my research and test, you could following the steps to make only emails from your main domain send to on-premises Exchange server.
1.Please disable the centralized tranpsort mode first. We could not create a connecotr from Office 365 to Internet. So we cannot create a transport rule to specify that users use a connector that is sent directly to the Internet. Disbale the centralized transport mode will send all emails directly to Internet.
2.Create a connector as below screenshot. Set to "From: Office 365" and "To: Your organization's email server". And select "Use only when I have a transport rule set up that redirects messages to this connector."
3.Create a transport rule as below screenshot. Set to use the specific connector you just created to send mail when the sending domain is your main domain, then the mail will be sent to your On-premises Exchange server. Initially, you can set "Apply this rule…" to a specific sender, then send a test email to external recipient and see if the email send to on-premises Exchange server first.If it succeeds, set it apply to all users in the domain, so as to prevent accidents from affecting the use of the user's mailbox.
The following is my test in lab environment:
1.I create a connector and transport rule as I mentioned above, then I send a email to external recipient. First, I check the message track in Exchange online and view the email send to my on-premises Exchange server.
2.Second, I check the message tracking log in on-premises Exchange, we could see that the email is transmitted in the on-premises Exchange server and sent out successfully.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.