From e726af8f837a5bf0229f90081a63bb5e410ba836 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 7 Sep 2016 12:56:19 +0100 Subject: [PATCH 1/4] add firewalld aliases --- plugins/firewalld/firewalld.plugin.zsh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 plugins/firewalld/firewalld.plugin.zsh diff --git a/plugins/firewalld/firewalld.plugin.zsh b/plugins/firewalld/firewalld.plugin.zsh new file mode 100644 index 000000000..52c5229a5 --- /dev/null +++ b/plugins/firewalld/firewalld.plugin.zsh @@ -0,0 +1,17 @@ +alias fw="firewall-cmd" +alias fwp="firewall-cmd --permanent" +alias fwr="firewall-cmd --reload" +alias fwrp="firewall-cmd --runtime-to-permanent" + +function fwl () { + # converts output to zsh array () + # @f flag split on new line + zones=("${(@f)$(firewall-cmd --get-active-zones | grep -v interfaces)}") + + for i in $zones; do + firewall-cmd --zone $i --list-all + done + + echo 'Direct Rules:' + firewall-cmd --direct --get-all-rules +} From e12f8e64ea1fe2871296f8acf541446a56cf5994 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 8 Sep 2016 00:05:43 +0100 Subject: [PATCH 2/4] sudo firewall-cmd calls --- plugins/firewalld/firewalld.plugin.zsh | 14 +++++++------- plugins/firewalld/readme.md | 0 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 plugins/firewalld/readme.md diff --git a/plugins/firewalld/firewalld.plugin.zsh b/plugins/firewalld/firewalld.plugin.zsh index 52c5229a5..bfbf6f48f 100644 --- a/plugins/firewalld/firewalld.plugin.zsh +++ b/plugins/firewalld/firewalld.plugin.zsh @@ -1,17 +1,17 @@ -alias fw="firewall-cmd" -alias fwp="firewall-cmd --permanent" -alias fwr="firewall-cmd --reload" -alias fwrp="firewall-cmd --runtime-to-permanent" +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)$(firewall-cmd --get-active-zones | grep -v interfaces)}") + zones=("${(@f)$(sudo firewall-cmd --get-active-zones | grep -v interfaces)}") for i in $zones; do - firewall-cmd --zone $i --list-all + sudo firewall-cmd --zone $i --list-all done echo 'Direct Rules:' - firewall-cmd --direct --get-all-rules + sudo firewall-cmd --direct --get-all-rules } diff --git a/plugins/firewalld/readme.md b/plugins/firewalld/readme.md new file mode 100644 index 000000000..e69de29bb From a64d018a9d483e0535d6d77d10c9ff2771d0cb41 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 8 Sep 2016 00:18:26 +0100 Subject: [PATCH 3/4] add readme --- plugins/firewalld/readme.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugins/firewalld/readme.md b/plugins/firewalld/readme.md index e69de29bb..611ad6de0 100644 --- a/plugins/firewalld/readme.md +++ b/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. + +``` +plugins=(... firewalld) +``` + +## Aliases + +| Alias | Command | Description | +| :---- | :----------------------------------- | :--------------------------- | +| fw | `firewall-cmd` | Shorthand | +| fwr | `firewall-cmd --reload` | Reload current configuration | +| fwp | `firewall-cmd --permanent` | Create permanent rule | +| fwrp | `firewall-cmd --runtime-to-permanent` | Save current configuration | + +## Functions + +| Function | Description | +| :------- | :--------------------------------------------------------- | +| fwl | Lists configuration from all active zones and direct rules | From db31d5157669b77b016a105dfdc53db9160a53d0 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 8 Sep 2016 00:27:46 +0100 Subject: [PATCH 4/4] corrected alias documentation --- plugins/firewalld/readme.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/firewalld/readme.md b/plugins/firewalld/readme.md index 611ad6de0..8b5bc74d4 100644 --- a/plugins/firewalld/readme.md +++ b/plugins/firewalld/readme.md @@ -2,18 +2,18 @@ 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 | `firewall-cmd` | Shorthand | -| fwr | `firewall-cmd --reload` | Reload current configuration | -| fwp | `firewall-cmd --permanent` | Create permanent rule | -| fwrp | `firewall-cmd --runtime-to-permanent` | Save current configuration | +| 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