I am trying to configure secure ssh connection from bastion host (located in public subnet) to private linux instances (located in private subnet) in the same VPC.
When I add a security group rule for my private linux instance, initially it shows the rule as:
Please note that before adding the IP address of the bastion host, the water mark shows "CIDR, IP or Security Group", but when I add the IP address of the bastion host, it throws error as:
The source needs to be a CIDR block or a Security Group ID.
Why is not allowing me to enter the IP address of the bastion host here?
Amazon EC2 and Amazon VPC support both the IPv4 and IPv6 addressing protocols.
Use the aws ec2 authorize-security-group-ingress command to add a rule to your security group.
To allocate and associate an Elastic IP address with your EC2 Windows or Linux instance, follow these steps: Allocate an Elastic IP address from either Amazon's pool of public IPv4 addresses or a custom IP address pool that you bring to your AWS account. Associate the Elastic IP address with a running instance.
It appears that your situation is:
I note that you are entering a Public IP address (52.63.198.234) in the Security Group. You should actually enter the Private IP address of the Bastion instance. This way, the traffic between the instances flows wholly within the VPC rather than leaving the VPC (to access the public IP address) and then coming back in again.
Actually, the recommended way to configure this setup is:
By referring to the name of a security group, traffic will automatically be permitted from any EC2 instance that is associated with the named security group (in this case, any instance that is associated with the Bastion-SG). This means that instances can be added/replaced and traffic will still be permitted based upon the associated security group, rather than having to update specific IP addresses.
So, to answer your question... Yes, there are three ways to refer to the source. From the EC2 documentation Security Group Rules:
- An individual IP address, in CIDR notation. Be sure to use the /32 prefix after the IP address; if you use the /0 prefix after the IP address, this opens the port to everyone. For example, specify the IP address 203.0.113.1 as 203.0.113.1/32.
- An IP address range, in CIDR notation (for example, 203.0.113.0/24).
- The name (EC2-Classic) or ID (EC2-Classic or EC2-VPC) of a security group.
So, the IP address actually has to use CIDR notation, with /32
at the end. If you think that this doesn't quite match the hint of "IP" (and I'd tend to agree with you), feel free to hit the Feedback button in the console and provide your feedback to the EC2 Console team.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With