Restricting Access to a Bucket for Specific IP Addresses
Scenario
This case describes how to restrict the source IP addresses that can access an OBS bucket. The following shows how to deny a client access whose source IP address is within the range of 114.115.1.0/24.
Recommended Configuration
Bucket policy
Procedure
- In the navigation pane of OBS Console, choose Object Storage.
- In the bucket list, click the bucket name you want to go to the Objects page.
- In the navigation pane, choose Permissions > Bucket Policy.
- On the Bucket Policies page, click Create.
- Locate the row containing Custom policy and click Create Custom Policy.
- Configure parameters for a bucket policy.
Figure 1 Configuring bucket policy parameters
Table 1 Parameters for configuring a bucket policy Parameter
Description
Policy View
Set this parameter based on your own habits. Visual editor is used here.
Policy Name
Enter a policy name.
Policy Content
- Select Deny.
- Parameters under Principal:
- Principal: Select Anonymous user.
- User Policy: Select Include specified users.
- Parameters under Resources:
- Resource: Select both Current bucket and Object in bucket.
- Object in bucket: Select All objects.
- Resource Policy: Select Include specified resources.
- Parameters under Actions:
- Select *, which indicates that all operations can be performed.
- Conditions:
- Key: Select SourceIp.
- Conditional Operator: Select IpAddress.
- Value: Enter 114.115.1.0/24.
NOTICE:
The IP address specified here is only for reference. Configure it based on the site requirements.
NOTE:If multiple IP addresses (CIDR blocks) need to be configured, separate them with commas (,).
These settings are only for restricting source IP addresses, but cannot distinguish whether they are from an intranet or from the Internet.
If you want to allow clients whose IP addresses are outside the configured range to access your bucket, grant access permissions to anonymous users by referring to Granting Permissions to Anonymous Users.
- After configuring the required parameters, click Next.
- Ensure all the configurations are correct and click Create.
Verification
Initiate an access request from an IP address within the range of 114.115.1.0/24. The access is denied. Initiate an access request from an IP address outside the range of 114.115.1.0/24. The access is allowed.
Related Scenarios
To allow only a specified IP address to access the OBS bucket, set Condition Operator to NotIpAddress and specify the allowed IP address as the Value.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.