Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration “DNS Resolution To Private IP Should Be Enabled” for an AWS EC2 instance using the AWS console, follow these steps:
- Log in to the AWS Management Console: Go to https://aws.amazon.com/ and log in to your AWS account.
- Navigate to the VPC Dashboard: In the AWS Management Console, navigate to the VPC Dashboard by selecting “Services” in the top menu, searching for “VPC” in the search bar, and clicking on “VPC”.
- Select Your VPC: In the VPC Dashboard, select the VPC that your EC2 instance is associated with from the list of available VPCs.
- Edit VPC Peering Connection: In the VPC Dashboard, click on “Peering Connections” in the left-hand menu. Find the peering connection associated with the VPC that your EC2 instance is in and select it.
- Edit Peering Connection Options: In the peering connection details, click on the “Actions” dropdown menu and select “Edit Peering Connection Options”.
- Enable Accepter/Requester VPC To Private IP: In the “Edit Peering Connection Options” window, find the option for “Accepter/Requester VPC To Private IP” and enable it by checking the box next to it.
- Save Changes: After enabling the “Accepter/Requester VPC To Private IP” option, click on the “Save Changes” button to apply the configuration.
- Verify Configuration: Once the changes are saved, verify that the “Accepter/Requester VPC To Private IP” is now enabled for the peering connection associated with your VPC.
Using CLI
Using CLI
To remediate the misconfiguration “DNS Resolution To Private IP Should Be Enabled” for AWS EC2 using AWS CLI, you can follow these steps:
-
Identify the security group associated with your EC2 instance:
-
Identify the VPC ID of your EC2 instance:
-
Enable “Accepter/Requester VPC To Private IP” setting in the security group:
Replace
<security-group-id>,<your-region>,<vpc-id>, and<ingress-rule>with the actual values. The<ingress-rule>should allow traffic from the VPC CIDR range to the private IP of the EC2 instance. -
Verify the changes:
Using Python
Using Python
To remediate the misconfiguration “DNS Resolution To Private IP Should Be Enabled” for AWS EC2 using Python, you can use the AWS SDK for Python (Boto3) to modify the VPC peering connection’s configuration. Here are the step-by-step instructions to remediate this issue:
-
Install Boto3:
If you haven’t installed Boto3, you can install it using pip:
-
Write a Python script to modify the VPC peering connection:
Use the following Python script to enable the “Accepter/Requester VPC To Private IP” option for a specific VPC peering connection in AWS EC2:
-
Replace
'YOUR_VPC_PEERING_CONNECTION_ID'with the actual VPC peering connection ID that you want to modify. -
Run the Python script:
Save the script in a file (e.g.,
remediate_vpc_peering_connection.py) and run it using Python:
Using Terraform
Using Terraform
requester block must be managed from the requester account’s Terraform, and the accepter block (or an aws_vpc_peering_connection_accepter resource with allow_remote_vpc_dns_resolution = true) must be managed from the accepter account’s Terraform.This change is an in‑place update and does not force replacement of the VPC peering connection.After updating the Terraform, terraform plan should show an in-place modification to the aws_vpc_peering_connection (and/or aws_vpc_peering_connection_accepter) resource, setting requester.allow_remote_vpc_dns_resolution and accepter.allow_remote_vpc_dns_resolution from false (or null) to true.
