There are a couple things you need to do if you don't want to share a link with Anyone:
- You need to invite users from externaldomain.com as guests users to your tenant.
- You then can build an Azure AD Dynamic membership group and share access with that group.
1) How to build an Azure AD Dynamic membership group that uses a contains operator for their e-mail domain.
Example:
(user.mail -contains 'externaldomain.com')
2) Once you have a dynamic membership group, you can share access with that group to grant them access.
Dynamic membership rules for groups in Azure Active Directory
https://learn.microsoft.com/en-us/azure/active-directory/enterprise-users/groups-dynamic-membership
Use Dynamic Groups to access SharePoint Online sites
https://blog.atwork.at/post/Dynamic-groups-accessing-SharePoint-Online
If you want to share a link with Anyone*:**
If this is helpful please accept answer.