In Office 365, how do you configure external collaboration settings but restrict certain domains from collaboration.
This is all configured under Azure Active Directory Admin Center.
A few clicks and your configured
User settings> External Collaboration Settings > Set the level of restrictions and Save. This example is restricting collaboration with *.outlook.com and *.hotmail.com domains
or if security if a higher priority over flexibility, Disable Members and Guests invite and set “Allow invitations only to the specified domains” Example :