For this we need to enable the external sharing for the site from SharePoint admin center, we need to follow the below steps to enable external sharing :
- Go to the Active sites page of the new SharePoint admin center, and
sign in with an account that has admin permissions for your
- In the left column, select a site.
- Select Sharing.
- Select an external sharing option
- If you want to limit the sharing of this site by domain, select the Limit sharing by domain check box, and add the domains that you want to allow or block.
- If you want to change the default sharing link type, permissions, or expiration setting for this site, clear the Same as organization-level settingcheck box and set the value that you want to use for this site.
- Select Save.
- For your scenario, need to select the below option :
Allow sharing with only people already in your directory. These users may exist in your directory because they previously accepted sharing invitations or because they were manually added. (You can tell an external user because they have #EXT# in their user name.)
Turn external sharing on or off for a site
For Managing sharing settings in tenant level, refer to the below MSDN article :
Manage sharing settings