0

Is it possible to find duplications in the security groups in AWS?

For example :

Security group 1 has : 198.168.5.2/24 , 192.168.4.2/24 , 172.54.60.12/24

Security group 2 has : 192.168.4.2/24 , 172.54.60.12/24 , 52.43.56.98/32

As you can see there are two exact same IPs in both SGs. Can this be done through AWS Cli ?

Rohamsk
  • 53
  • 10

1 Answers1

1

Yes, you can use the ip-permission.cidr filter for this. From the documentation:

ip-permission.cidr - An IPv4 CIDR range that has been granted permission in a security group rule.

So you can use this to specify the CIDR range you want to check for, and it will list only the security groups containing a rule matching that CIDR range.

Example command:

aws ec2 describe-security-groups --filters Name=ip-permission.cidr,Values=172.54.60.12/24

Further reading:

Anthony Neace
  • 25,013
  • 7
  • 114
  • 129