Skip to content

Shashwatsingh22/Dynamically-Firwall-Update

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

Dynamically Firewall Update

Modules

  1. API
  2. Python Script
  3. Ansible Role
  4. Jenkinsfile

Demo🎬

Demo

Problem Statement

A company has a server(S) running on Linux hosted somewhere which is publicly accessible. You need to restrict its access to only 2 whitelisted IP addresses: 210.212.85.155 and X on ports 22, 443, 80.

X is the IP address of this company's headquarters.

The company's headquarters does not have a static IP and keeps on changing, which requires staff to manually grant the access to the new IP address.

Approach

  • For fetching the IP created an API which will hosted at Server-X (On GET request to this route /getUpdatedIP) (Create API by NodeJS)

  • Created an Python Script which making the GET request and find the IP after that it will check with exitsing one where it is mainting IP data in an variable file (of ansible),

    • If that last IP not matches with current IP then it will update the variable file of the ansible where deny-var now become the previous IP and allow-var become the current IP.
    • Else it will exit with message (IP not change).
  • For Configuring Firewall Created an Ansible Role. - First Deny the traffic from the last IP (Getting last IP by the Help of Variable File) on respected Port number's. - Then allow the traffic for new IP on respected Port number's.

  • Python Script can be triggered by two ways :-

Complete Architecture Structure

ArchIMP1.1

Working

ArchIMG1.2