Skip to content

stinky-fox/opennebula-security-group-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Security Group Rule Generator

This script helps generate security group rules based on a list of IP ranges.
It accepts several command-line arguments for configuration.

Requirments

argparse
ipaddress

Arguments

Argument Aliases Default Description
--source --src ips.txt Source file containing IP ranges.
--export --exp rules.txt Export file where generated rules will be saved.
--direction inbound Direction of the traffic (inbound or outbound).
--protocol TCP Protocol to use (TCP or UDP).
--ports None Port range(s) in valid iptables syntax (e.g., 22, 53, 80:90, 110, 1024:65535).
--name My SG Name of the Security Group.

Input file sample

173.245.48.0/20
103.21.244.0/22
103.22.200.0/22
103.31.4.0/22
141.101.64.0/18
108.162.192.0/18
190.93.240.0/20

Output file sample

RULE=[
    IP="173.245.48.1",
    PROTOCOL="TCP",
    RANGE="22,80",
    RULE_TYPE="inbound",
    SIZE="4094" ]
RULE=[
    IP="103.21.244.1",
    PROTOCOL="TCP",
    RANGE="22,80",
    RULE_TYPE="inbound",
    SIZE="1022" ]
RULE=[
    IP="103.22.200.1",
    PROTOCOL="TCP",
    RANGE="22,80",
    RULE_TYPE="inbound",
    SIZE="1022" ]
RULE=[
    IP="103.31.4.1",
    PROTOCOL="TCP",
    RANGE="22,80",
    RULE_TYPE="inbound",
    SIZE="1022" ]
RULE=[
    IP="141.101.64.1",
    PROTOCOL="TCP",
    RANGE="22,80",
    RULE_TYPE="inbound",
    SIZE="16382" ]
RULE=[
    IP="108.162.192.1",
    PROTOCOL="TCP",
    RANGE="22,80",
    RULE_TYPE="inbound",
    SIZE="16382" ]
RULE=[
    IP="190.93.240.1",
    PROTOCOL="TCP",
    RANGE="22,80",
    RULE_TYPE="inbound",
    SIZE="4094" ]
NAME="Web SG"

Create and Use with OpenNebula CLI

python builder.py --source ips.txt --export rules.txt --direction inbound --protocol TCP --ports 22,80 --name "Web SG"
onesecgroup create rules.txt

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages