summaryrefslogtreecommitdiffstats
path: root/zsh/oh-my-zsh/plugins/firewalld
diff options
context:
space:
mode:
authorLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2022-10-03 21:42:20 +0530
committerLibravatarLibravatar Biswakalyan Bhuyan <biswa@surgot.in> 2022-10-03 21:42:20 +0530
commitaf120ab348f2e1a5a39dec035ed9dcf84189a64e (patch)
tree2a3aadd7ce1b7b771dfe3fe7c983569726c8d7ed /zsh/oh-my-zsh/plugins/firewalld
downloaddotfiles-af120ab348f2e1a5a39dec035ed9dcf84189a64e.tar.gz
dotfiles-af120ab348f2e1a5a39dec035ed9dcf84189a64e.tar.bz2
dotfiles-af120ab348f2e1a5a39dec035ed9dcf84189a64e.zip
dotfiles
Diffstat (limited to 'zsh/oh-my-zsh/plugins/firewalld')
-rw-r--r--zsh/oh-my-zsh/plugins/firewalld/README.md22
-rw-r--r--zsh/oh-my-zsh/plugins/firewalld/firewalld.plugin.zsh17
2 files changed, 39 insertions, 0 deletions
diff --git a/zsh/oh-my-zsh/plugins/firewalld/README.md b/zsh/oh-my-zsh/plugins/firewalld/README.md
new file mode 100644
index 0000000..8b5bc74
--- /dev/null
+++ b/zsh/oh-my-zsh/plugins/firewalld/README.md
@@ -0,0 +1,22 @@
+# FirewallD Plugin
+
+This plugin adds some aliases and functions for FirewallD using the `firewalld-cmd` command. To use it, add firewalld to your plugins array.
+
+```zsh
+plugins=(... firewalld)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+| :---- | :----------------------------------------- | :--------------------------- |
+| fw | `sudo firewall-cmd` | Shorthand |
+| fwr | `sudo firewall-cmd --reload` | Reload current configuration |
+| fwp | `sudo firewall-cmd --permanent` | Create permanent rule |
+| fwrp | `sudo firewall-cmd --runtime-to-permanent` | Save current configuration |
+
+## Functions
+
+| Function | Description |
+| :------- | :--------------------------------------------------------- |
+| fwl | Lists configuration from all active zones and direct rules |
diff --git a/zsh/oh-my-zsh/plugins/firewalld/firewalld.plugin.zsh b/zsh/oh-my-zsh/plugins/firewalld/firewalld.plugin.zsh
new file mode 100644
index 0000000..5b10906
--- /dev/null
+++ b/zsh/oh-my-zsh/plugins/firewalld/firewalld.plugin.zsh
@@ -0,0 +1,17 @@
+alias fw="sudo firewall-cmd"
+alias fwp="sudo firewall-cmd --permanent"
+alias fwr="sudo firewall-cmd --reload"
+alias fwrp="sudo firewall-cmd --runtime-to-permanent"
+
+function fwl () {
+ # converts output to zsh array ()
+ # @f flag split on new line
+ zones=("${(@f)$(sudo firewall-cmd --get-active-zones | grep -v 'interfaces\|sources')}")
+
+ for i in $zones; do
+ sudo firewall-cmd --zone $i --list-all
+ done
+
+ echo 'Direct Rules:'
+ sudo firewall-cmd --direct --get-all-rules
+}