HitLuca / digitalocean-firewalls-ip-changer

Automatically update your DigitalOcean firewalls with your new public ip

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DigitalOcean Firewalls IP changer

image

image

image

This personal project aims to give an easy and automated way to access resources created using the DigitalOcean service, but blocked behind firewalls. Especially during the current global crysis (great covid-19 pandemic of the 21st century), developers need to work from home, and in order to access remote services they need to update the company's firewalls with their updated ip.

Features

  • Automated removal of your old ip from the firewalls
  • Automated addition of your new ip to the firewalls
  • Supports creating multiple firewall rules, and for multiple firewalls
  • Easy to understand yaml config file, in which all the ip history is also kept

Installation

This project requires python to be installed, and at least at version 3.6

This project works using poetry (https://python-poetry.org/docs/) to create a virtual environment and not pollute system interpreters. Make sure to install it in order to use this project.

This project also requires doctl, a DigitalOcean cli interface. For this reason, first do the following:

A guide that describes all the features of doctl can be found here. After doctl is installed, install the project by running:

Running the project

To run the project, simply

If it's your first time running the project, please check the info messages and update your config file accordingly!

The config file

In order to store all the past ips (for reference), the firewall settings, and everything that could be needed, this project uses a yaml configuration file

config.yaml

  • firewalls is a list of firewalls you want to update
    • firewall_id indicates the DigitalOcean id assigned to a particular firewall
    • rules contains each rule to be updated
      • protocol should be kept equal to tcp
      • ports is the port you will need to use as a remote developer, in this example 80, 443, or 1337
  • last_ip is the last ip recorded, usually your current one
  • past_ips are all the past ips you had, for reference, should any issues arise

How to find the firewall_id

If the firewall which requires updates hasn't been renamed from its original id, congratulations! This is the id you need to use (an example id is abc-12b123jl-34k2-3j1n-532j-as234jlb2)

If the firewall id has been updated to something different than the original, then you need to retrieve it:

  • List your firewalls, using doctl compute firewall list
  • Find your firewall_id

Contribute

Support

If you are having issues, please let me know. This is a personal project, but if general interest is shown, I'll make sure to put more work into it

License

The project is licensed under the MIT license.

Planned Features

  • Ensure that doctl is installed before running any operations

About

Automatically update your DigitalOcean firewalls with your new public ip

License:MIT License


Languages

Language:Python 100.0%