set dynamic ip in security group, in AWS hosting? - amazon-web-services

I have created a security group in aws.amazon.com hosting.
I have set SSH to custom IP.
My problem is that my IPs are dynamic with in a range:
For example,
217.206.204.200
217.206.203.215
217.206.201.295
I want to create one rule for SSH custom IPs. So that all IPs have starting 217.206 can connect to server.
How can I do this?

217.206.0.0/16
This expression in the "Custom IP" box would allow every IP from 217.206.0.0 through 217.206.255.255, inclusive.
This is called CIDR notation.
The numbet after the slash is the prefix. An IPv4 address is 32 bits wide. The prefix indicates which bits of the address being compared must match the address specified. In this case, if the first 16 bits of the address of the connecting machine are "217" followed by "206" then the remaining bits of the address can be anything, and the rule will match that source IP.
http://en.m.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation

Related

How do I add an ip range to aws?

I haven't found anything that details out how to add a range through the AWS portal. I have a range of salesforce ids that I need to add. When i set the server to only allow from specific ids I'm unable to reach the server by adding the basic single addresses. I found an address in the first range which allowed traffic, but when I've restricted access to only the listed ips I'm unable to ping salesforce from the server. I have all outbound traffic allowed. Also, when I allow all traffic, I am able to ping in both directions. I have very limited network experience, so any help is appreciated. Here is an example of the first ARIN range 13.108.0.0 - 13.111.255.255
If you have a range like 13.108.0.0 - 13.111.255.255 first convert that to a CIDR range using a web site that can do the conversion: wmtips
Then add the CIDR address to the inbound rules of the security group attached to your EC2 (Make sure the correct protocol is selected). This is to allow access for the remote system. Set the outbound rules on the security group to 0.0.0.0/0.

Error when creating private subnets within AWS VPC

I am currently trying to create a VPC with multiple subnets in AWS. Unfortunately, whenever I go to design the subnets within the VPC I am getting errors. This is my VPC design:
VPC: 10.82.0.0/16
Private Subnets:
10.82.96.0/21
10.82.119.0/21
10.82.194.0/21
10.82.212.0/21
The Error I get is the following for each subnet CIDR except 10.82.96.0/21:
Must be a valid CIDR block.
What am I doing wrong? I just want to create multiple private subnets in this VPC.
A /21 is quite an unusual netmask to be using. It contains 2048 IP addresses.
The netmask for /21 would be:
11111111.11111111.11111000.00000000
Only the zeroes are allowed to change. In binary, 100000000000 is equivalent to 2048 in decimal and 1000 in binary is 8 in decimal.
This means that the second last number would be a multiple of 8 (eg 0, 8, 16, 32).
However, you have not chosen IP addresses that start in a /21 range.
Your chosen subnets would have the following IP address ranges:
CIDR First address Last address
10.82.96.0/21 10.82.96.0 10.82.103.255 Good!
10.82.119.0/21 10.82.112.0 10.82.119.255 Invalid
10.82.194.0/21 10.82.192.0 10.82.199.255 Invalid
10.82.212.0/21 10.82.208.0 10.82.215.255 Invalid
Note that the first line is good because 96 is divisible by 8. Therefore, it is valid in a /21 CIDR.
However, the subsequent lines do not start on a /21 boundary. They are invalid CIDR values.
I highly recommend using a CIDR calculator when determining difficult IP ranges.

Why is 10.0.0.1/28 not a valid subnet within a VPC of 10.0.0.0/24?

How to create Multiple Subnets within Range 10.0.0.0/24.
Tried creating 10.0.0.1/28 . It tells it should be within the CIDR Range.
I am sure am making something wrong . Please advise.
If you have a VPC has : 10.0.0.0/24. then you want to create some subnets are being this VPC.
If you want to create subnet with /28 so:
10.0.0.0/28
10.0.0.16/28
10.0.0.32/28
10.0.0.48/28
10.0.0.64/28
............
10.0.0.240/28
If you want to create subnet with /26:
10.0.0.0/26
10.0.0.64/26
10.0.0.128/26
10.0.0.192/26
The message is misleading. It is not like 10.0.0.1/28 is not within the CIDR range of 10.0.0.0/24, it simply is an incorrect network ID (the message could be slightly more helpful I guess).
You can only specify network ID, not a network address. In your case 10.0.0.1/28 is the first network address from range 10.0.0.0 - 10.0.0.15 where 10.0.0.0/28 is the network ID that you need to use instead. The next network ID for /28 prefix length is 10.0.0.16 as it was mentioned in the other answer.
This is given by subnetting rules. Long story short, if you need to know network IDs then just subtract the prefix, in this case 28 from 32 (32 bits of IPv4 address) which gives you 4 usable bits for hosts which translates to 2^4 = 16 block size. Therefore you can start with 10.0.0.0 and continue by adding 16 to the last number 0, 16, 32, 48, ... and the same goes for the other prefixes as well (or at least if you consider any prefix longer or equal to 24, it kind of works for shorter prefixes as well but you need to be careful which octet of IP address you are modifying).
It is also worth mentioning that the 10.0.0.1/28 is not even a usable IP address on AWS because AWS reserves first 4 and the last one IP address of each subnet (first 4, including network ID, are used for stuff such as DHCP server in your subnet which you don't directly see and the last one is broadcast address which, in general, cannot be assigned to any host, moreover AWS doesn't even support broadcasts).
So technically, when you use 10.0.0.0/28 subnet, you will end up with 11 available IP addresses ranging from 10.0.0.4 to 10.0.0.14.

Get IP with subnet mask for use with AWS EC2 SSH

When setting up an EC2 instance AWS Console has a useful feature to find your current IP address complete with subnet mask for whitelisting. Here is the UI I'm sure we have all seen.
This is convenient when you are setting it up but if you need to white list a remote DEV's home WIFI or you are using cloudformation it is not longer convenient to get the IP address this way.
So, is there a convenient way to print out your IP address complete with the subnet mask (/) from your terminal? I have not found one.
If you're on linux or mac it's fairly simple to do a ip addr show or assign to a variable with IP_ADDR=$(ip addr show).
On windows, there's a PowerShell module you can use.
Invoke-WebRequest ifconfig.me/ip
though that prints out more than just the IP, you can always parse it.
Ok, I realized I did not understand CIDR notation and subnet masking.
Basically AWS requires CIDR notation and CIDR notation allows you to specify a range of addresses. It works out that the /32 means a range of 0 so the address is everything to the left of the /.
So, to whitelist a single IP you say myIP/32

aws security groups - group to group

Hi have issues with securithy groups on aws.
Assume I have two sec groups:
sg-d774eeed (secA)
sg-d787eady (secB)
I want secA to have access to port 9999 on secB.
In the source input box I will add sg-d774eeed with port 9999.
Commit the changes.
Nothing works
So I need to input sg-d774eeed/0 sg-d774eeed/32 or something like that?
You can create just one security group with port 9999, enter the same security group name in the source and assign this security group to both instances that you want to communicate together. However, to make that happen, you need to use either Private IP i.e. 172.1.2.3 or Public DNS i.e. ec2-54-1-2-3.eu-west-1.compute.amazonaws.com.
Port Range Source
9999 sg-abcdef
The best is to use Public DNS because:
When an EC2 instance queries the external DNS name of an Elastic IP, the EC2 DNS server returns the internal IP address of the instance to which the Elastic IP address is currently assigned.