This article explains how to avoid being contacted on an iPhone by users whose number has been blocked or has not been saved in the address book.
Steps
Method 1 of 3: Using the "Do Not Disturb" Option

Step 1. Open the iPhone settings
The application depicts a gray gear and is located on the main screen.

Step 2. Tap Do Not Disturb
This section is located at the top of the menu, next to a purple icon containing a moon.

Step 3. Tap Allow Calls From
It is located towards the center of the screen.
Step 4. Tap All Contacts
It is located in the section of the menu called "Groups". At this point, having activated the "Do not disturb" function, only the numbers saved in the phone book will be able to contact you.
To turn Do Not Disturb on or off, slide your finger up on the home screen or lock screen and tap the crescent moon icon at the top of the Control Center
Method 2 of 3: Block Calls From Unknown Numbers

Step 1. Open the "Phone" application
It is a green app which is located at the bottom left of the main screen. Contains a handset icon.

Step 2. Tap Contacts
It is located at the bottom of the screen (in the center) and contains the silhouette of a person.

Step 3. Tap +
It is located at the top right.

Step 4. Type "Unknown" in the fields corresponding to the first and last name

Step 5. Tap Save
It is located at the top right.

Step 6. Tap Block this contact
It is located at the bottom of the screen.

Step 7. Tap Block Contact
At this point you should have blocked most of the calls indicated by "Unknown".
Friends who call from an unknown number will not be able to reach you
Method 3 of 3: Block Calls from Unrecognized Numbers

Step 1. Open the "Phone" app
It looks like a green icon and is located at the bottom left of the main screen. Contains a handset.

Step 2. Tap Recent
The icon looks like a clock and is located at the bottom left.

Step 3. Tap ⓘ next to the number you don't recognize
It's a blue icon on the right side of the screen.

Step 4. Scroll down and tap Block this contact
It's at the bottom of the menu.

Step 5. Tap Block Contact
At this point, calls from this number will not be able to reach your iPhone.