Step 1: Sign in to the Microsoft 365 admin center
Step 2: Go to admin panel
Step 3: Now select SharePoint admin center
Step 4: Select Access control page in the sharepoint admin center
Step 5: Select Network location, and turn on Allow access only from specific IP address ranges
Step 6: Enter IP addresses and address ranges separated by commas that you want to allow access to sharepoint and onedrive
Step 7: Click save.