问题原文
原帖链接 · leonbloy · CC BY-SA 3.0
I'm migrating from iptables to firewalld, using Centos 7.
In the old times, I used to write the (permament) iptables rules in the /etc/sysconfig/iptables , which also served to place comments prepended by # (to remind us why we restricted this or that ip, etc).
Now, it seems that the current (permanent) configuration is read from /etc/firewalld/ files (especially /etc/firewalld/zones/*.xml). I guess I could add xml comments there, but it seems the good practice is not to edit those files directly but via firewall-cmd (no?).
Hence, I'm not sure which is the standard or recommended way to add comments to the rules.
Any suggestions?
Edited: For the record, I've verified that xml comments do not survive firewall-cmd modifications.
已采纳解答
原帖链接 · leonbloy · CC BY-SA 4.0
Thinking it over, I'm finding this firewalld-cmd thing slightly silly. After all, XML configuration files are human editable. It makes little sense to me, having to learn an extra layer of commands (well, one command, but with tons of arguments) only to edit some simple and neat XML files (*).
I fell slightly stupid typing
firewall-cmd --permanent --zone=work --add-port=445/tcp
just for addding the following line to /etc/firewalld/zones/work.xml
<port protocol="tcp" port="445"/>
Hence, at least for now, and considering that the XML elements don't include comment attributes (there are some requests in that direction) I'm leaning towards the following strategy: just forget about firewalld-cmd (perhaps even delete it), edit the XML files yourself, and add XML comments freely.
(*) It's true that firewalld-cmd allows also to add dynamic (non permanent) rules. But I'd bet that that is not a very frequent scenario.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
