如何将AWS EC2实例上的大量IP地址列表?

发布于 2025-02-09 10:39:42 字数 253 浏览 3 评论 0 原文

我有大量的IP(> 100)清单,需要在EC2实例上进行入站和出站通信。有没有办法集体白名单? (IPS也不属于范围,并且是不连续的)。我们使用安全组用于白名单IP的安全组很弯腰,但是我找不到一种简单的方法来将大量的IPS集成。

PS-我尝试在AWS WAF中探索IP集,但是它需要设置应用程序负载均衡器,此外,由于我们已经在使用安全组,因此在应用程序层(通过WAF)阻止IPS(通过WAF)也将阻止已经在该ips上列入白色的IP EC2级别。

提前致谢!

I have a large list of IPs (>100) that need to be whitelisted for both inbound and outbound communication on EC2 instances. Is there a way to whitelist them collectively? (The IPs also don't belong to a range and are discontinuous). We are currenlty using security groups for whitelisting IPs, but I couldn't find an easy way to whitelist a large collection of IPs.

PS- I tried exploring IP sets in AWS WAF, but it requires setting up an application load balancer, additionally since we are already using security groups, blocking IPs at the application layer (via WAF) will also block IPs that are already whitelisted at the EC2 level.

Thanks in Advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

久光 2025-02-16 10:39:42

您可以使用托管前缀列表您使配置和维护安全组更容易。

请记住,前缀列表中的每个条目通常在您的SG中计数,因此您可能需要要求增加默认配额(每个安全组60个入站和60个出站规则)。

You can use managed prefix lists which allows you to make it easier to configure and maintain your security groups.

Keep in mind that every entry in the prefix list count as a rule in your SG, so probably you will need to request an increase of the default quota (60 inbound and 60 outbound rules per security group).

说不完的你爱 2025-02-16 10:39:42

对于EC2端口,您获得的最佳选择是安全组。但是,您最好使用IAC来管理诸如Terraform或CloudFormation之类的它 - 它将帮助您更好地管理IP列表并将它们全部保存在一个文件中。

这是Terraform的参考:

For an EC2 port access the best option you got is security groups. But you better use IaC to manage this such as Terraform or CloudFormation - it will help you to better manage the IP list and save them all in one file.

Here is a reference for Terraform: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group

递刀给你 2025-02-16 10:39:42

另一个简单的选择是,您维护CSV文件以存储IP地址并使用Python脚本来更新您的安全组。由于使用Excel/CSV文件更受欢迎,因此您可以轻松地找到python脚本来读取CSV文件和使用Boto3来更新您的安全组。

Another easy option is you maintain a csv file to store IP addresses and use a python script to update your security group. Since working with Excel/csv files are more popular you can easily find python scripts to read csv files and the use boto3 to update your security group.

叹沉浮 2025-02-16 10:39:42

在安全组中维持白名单的IP,这是我相信的最佳选择,您不需要入站和出站。
由于安全组是有状态的,因此您需要仅在入站规则中提及白名单的IP。
您可能有不同的出站用例,我不确定

但是,我认为通过自动化处理它的最佳方法。您可以创建一个具有不同规则条目的DynamoDB表,启用DynamoDB流,任何更改都会触发一个lambda,该lambda会创建/修改与EC2关联的安全组。

Maintaining the whitelisted IPs in a Security group, which is the best option I believe, you don't need for both inbound and outbound.
Since Security group is stateful, you need to mention whitelisted IPs in inbound rule only.
(You may have different use case for outbound, which I am not sure)

However, I think the best way to handle it via an automation. You can create a Dynamodb table with different rule entries, enable dynamodb stream, any change triggers a Lambda which inturn creates/amends security group associated with the EC2.

晚风撩人 2025-02-16 10:39:42

我知道这很晚,但是如果基于Linux的Linux,则可以允许所有IPS上的所有IPS,然后设置Iptables以明确允许这些IP地址并阻止其他任何内容。

iptables -A INPUT -s ip1,ip2,ip3 -j ACCEPT
iptables -A INPUT -s 0.0.0.0/0 -d ip2 -j DROP

I know it's pretty late but you can allow all IPs on your security group and inside your ec2 machine if it's Linux based then set iptables to explicitly allow those ip addresses and block anything else.

iptables -A INPUT -s ip1,ip2,ip3 -j ACCEPT
iptables -A INPUT -s 0.0.0.0/0 -d ip2 -j DROP
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文