0
IFS=$'\n'; for i in `firewall-cmd --direct --get-all-rules`; do firewall-cmd --permanent --direct --remove-rule $i && firewall-cmd --reload; done

The above command throws error as usage: --permanent --direct --remove-rule { ipv4 | ipv6 | eb }

After I enabled shell verbose option, I noticed that the command is as follows:

firewall-cmd --permanent --direct --remove-rule 'ipv4 filter OUTPUT 2 -o ens32 -p udp -m conntrack --ctstate NEW -j ACCEPT'

I am not really sure from where the single quotes around the rule is getting substituted and how to get rid of it.

Ibrahim Quraish
  • 3,889
  • 2
  • 31
  • 39
  • Setting IFS : `IFS=$'\n';` has for effect of changing the word splitting delimiter. what is the output of `firewall-cmd --direct --get-all-rules`, the single quotes do not belong to arguments but are shown when displaying the command to facilitate the replay – Nahuel Fouilleul Jan 30 '19 at 13:41
  • `firewall-cmd --direct --get-all-rules` gives the output properly without single quotes. But when I used it in the script I am facing the issue – Ibrahim Quraish Jan 31 '19 at 05:16
  • the quotes are bash syntax to avoid argument splitting, are added by bash when displaying the command (xtrace), but `i` variable doesn't contain quotes. Because space is no more a IFS character the firewall-cmd output isn't split on spaces – Nahuel Fouilleul Jan 31 '19 at 06:19

0 Answers0