2

一个自动修改安全组规则的项目

 1 year ago
source link: https://www.bboy.app/2023/02/22/%E4%B8%80%E4%B8%AA%E8%87%AA%E5%8A%A8%E4%BF%AE%E6%94%B9%E5%AE%89%E5%85%A8%E7%BB%84%E8%A7%84%E5%88%99%E7%9A%84%E9%A1%B9%E7%9B%AE/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

一个自动修改安全组规则的项目

February 22, 2023
20230222-3.webp

之前的公司办公地方用的是普通的宽带,有一些服务是部署在阿里云上的,为了保证安全就要设置安全组的白名单,但是宽带对外的ip是不固定的,所以就需要在一台机器上跑这个然后检测到ip修改掉之后就自动更新安全组上的策略,改完之后企业机器人会提醒修改成了什么

https://github.com/bboysoulcn/aliyunsg-auto

首先clone代码

git clone [email protected]:bboysoulcn/aliyunsg-auto.git

之后修改配置

vim config.ini

[conf]
wechat_boot_url = # 企业微信通知机器人
access_key =
access_secret =
area = # 地域
sgid = # 安全组的id

[rule1]
policy=Accept # 策略
priority=1 # 优先级
protocol=TCP # 协议
port_range=101/150 # 端口范围
description=frp #描述

[rule2]
policy=Accept
priority=1
protocol=TCP
port_range=8443/8444
description=k8s

如果你有多个安全组规则,那么就一直往下加就好了rule3,rule4什么的

之后运行就好了

bash start.sh

目前只支持企业微信机器人告警,如果有需求我可以改下

欢迎关注我的博客www.bboy.app

Have Fun


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK