
linux hortelã.sem nome -rrendimentos5.15.0-56.dpkg-query -l bashrendimentos5.1.6ubuntu1.
Meu script mostra essa saída problemática quandoscript bash -xinvocado:
attrib =' '\''{type nat hook prerouting priority mangle+10;}'\'' '
Mas na linha de comando:
sudo nft create chain inet firewalld mangle_PREROUTING '{ type nat hook prerouting priority mangle + 10 ;}'
Funciona bem.
Este script replica a árvore fedora nft.
x=$(sudo nft -a list tables)
if [[ $x != '' ]]; then
sudo nft flush table inet firewalld
sudo nft delete table inet firewalld
fi
sudo nft create table inet firewalld
for stage in mangle net filter;do
for step in _PREROUTING _OUTPUT _INPUT _IN_workstation; do
meat=${step/_/}
priority=${stage/_/}
a=${step/_[a-zA-Z]+/_}
b=${stage/_[a-zA-Z]+/_}
if [[ $stage =="__"]]; then
type="nat"
else
type="filter"
fi.
hook=${meat,,} #translate to all lowercase.
attrib=" '{ type "$type" hook "$hook" priority "$priority"+10;}'"
if[[ $a$b == "__" ]]; then
cmd=" insert rule inet firewalld $stage$step" ;
sudo nft $cmd
else
cmd=" create chain inet firewalld $stage$step $attrib";
sudo nft $cmd
fi
done
done
Responder1
Remover as aspas simples em torno das chaves foi a resposta. Eu tentei isso porque imaginei que o shell script (e o sudo) estavam fazendo um fork/exec, para nft, sem interpretação do shell.