From 35d1748b8a363c4c598a1e7759ee5642b9f64739 Mon Sep 17 00:00:00 2001 From: Kshitij Date: Tue, 19 Nov 2024 00:01:46 +0530 Subject: [PATCH] Added firewall script and updated link in readme file. --- README.md | 4 ++++ firewall.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100755 firewall.sh diff --git a/README.md b/README.md index 8e2d970..c4ef64b 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,7 @@ This repo contains scripts written by me for simplifying my life. --- + +- [firewall](https://git.kska.io/notkshitij/scripts/src/branch/main/firewall.sh) - This is a shell script for automatically setting up the firewall on my laptop. Pretty basic stuff using ufw, nothing too fancy! + +--- diff --git a/firewall.sh b/firewall.sh new file mode 100755 index 0000000..ced38bf --- /dev/null +++ b/firewall.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +echo -e "--- MAIN MENU ---\n1. Home profile\n2. Public profile\n3. PANIC MODE\n4. Exit" +read -p "Choose an option: " optn + +case optn in + 1) # Home profile + for i in {0..5} + do + yes | sudo ufw delete 1 + done + sudo ufw default deny incoming + sudo ufw default allow outgoing + sudo ufw status verbose + sudo ufw allow in from any to any port 1714:1764 proto tcp # KDE TCP + sudo ufw allow in from any to any port 1714:1764 proto udp # KDE UDP + sudo ufw allow in from 192.168.219.0/24 to any port 22000 # Syncthing TCP + sudo ufw allow in from 192.168.219.0/24 to any port 21027 proto udp # Syncthing UDP + sudo ufw reload + sudo ufw status verbose + ;; + 2) # Public profile + for i in {0..5} + do + yes | sudo ufw delete 1 + done + sudo ufw default deny incoming + sudo ufw default allow outgoing + sudo ufw status verbose + ;; + 3) # Panic mode + for i in {0..7} + do + yes | sudo ufw delete 1 + done + sudo ufw default deny incoming + sudo ufw default deny outcoming + sudo ufw status verbose + ;; + *) # Default + echo 'Please choose a valid option (1-4).' + ;; +esac