在aws ec2中查找可用的ip地址块
vpc-free的Python项目详细描述
此脚本在未分配的 vpc子网之间的空间,或给定cidr块的vpc之间的空间。
安装
使用以下命令将vpc-free安装到/usr/local/bin:
$ pip install vpc-free
该脚本使用amazon aws sdk(boto3)连接到aws。sdk必须 配置凭据以连接到aws api。有关说明,请参见Boto3 documentation。
用法
$ vpc-free -h usage: vpc-free [-h] TARGET Find free IP blocks in AWS EC2. positional arguments: TARGET CIDR, VPC ID or VPC Name to search optional arguments: -h, --help show this help message and exit
示例
# search for unallocated blocks between VPCs in 10.0.0.0/8 $ vpc-free 10.0.0.0/8 MIN IP MAX IP MASK SIZE BEST LABEL 10.0.0.0 10.63.255.255 /10 419430410.0.0.0/10 FREE 10.64.0.0 10.64.255.255 /16 65536 vpc-c4871ca0 (Demo)10.65.0.0 10.255.255.255 1251737610.128.0.0/9 FREE # search for unallocated blocks between subnets in a VPC $ vpc-free vpc-c4671caf 10.64.0.0 10.64.15.255 /20 4096 subnet-74247002 (Subnet 1)10.64.16.0 10.64.31.255 /20 4096 subnet-d32421a5 (Subnet 2)10.64.32.0 10.64.47.255 /20 409610.64.32.0/20 FREE 10.64.48.0 10.64.63.255 /20 4096 subnet-0a257077 (Subnet 4)10.64.64.0 10.64.255.255 4915210.64.128.0/17 FREE