AWS安全组入站规则批量添加CIDR
1.准备一个CIDR网段的文件
如:
iplist.txt
192.168.0.0/24
192.168.1.0/24
192.168.2.0/24
2.编写如下脚本(需要提前安装配置AWS CLI)
#!/bin/bash
cat iplist.txt | while read line
do
aws ec2 authorize-security-group-ingress --group-id sg-062bb8faf2140f07f --ip-permissions IpProtocol=tcp,FromPort=443,ToPort=443,IpRanges="[{CidrIp=$line}]"
done
——本文作者:赵毅鹏,沈磊