Created
August 19, 2025 05:25
-
-
Save krotesk/fafbb9e2362323c6558a438fa97fbdad to your computer and use it in GitHub Desktop.
Add addresses as dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| readonly connections=( | |
| '192.168.1.4/24|tcp|22' | |
| '192.168.1.5/24|tcp|53' | |
| '192.168.1.6/24|tcp|80' | |
| '192.168.1.7/24|tcp|139' | |
| '192.168.1.8/24|tcp|443' | |
| '192.168.1.9/24|tcp|445' | |
| '192.168.1.10/24|tcp|631' | |
| '192.168.1.11/24|tcp|5901' | |
| '192.168.1.12/24|tcp|6566' | |
| ) | |
| function set_connections(){ | |
| local range proto port | |
| for fields in ${connections[@]} | |
| do | |
| IFS=$'|' read -r range proto port <<< "$fields" | |
| echo "ufw allow from ${range} proto ${proto} to any port ${port}" | |
| done | |
| } | |
| set_connections |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment