在 CentOS/RHEL 8 中,默认的 iptables 网络包过滤框架被 nftables 框架取代。
作为 iptables、ip6tables、arptables 和 ebtables 的指定继承者,nftables 框架包括数据包分类工具和多项改进,与以前使用的数据包过滤工具相比,它们提供了更多的便利和改进的性能。
在这篇文章中,我们将讨论如何将现有的 iptables 规则迁移到 CentOS/RHEL 7 中的 nftables。
在 CentOS/RHEL 6,7 中显示退出 iptable 规则
在 CentOS/RHEL 6,7 服务器上显示现有规则:
# iptables -L DROP udp -- anywhere anywhere multiport dports epmap,microsoft-ds DROP udp -- anywhere anywhere udp dpts:netbios-ns:netbios-ssn DROP udp -- anywhere anywhere udp spt:netbios-ns dpts:1024:65535 DROP tcp -- anywhere anywhere multiport dports epmap,netbios-ssn,microsoft-ds
on it road.com
操作步骤
- 要将现有规则保存到文件中,请运行以下命令:
# iptables-save > rules.iptables
通过 scp 或者 ftp 将 step1 文件移动到 CentOS/RHEL 8 Server。
我们也可以使用 vi 编辑器从 CentOS/RHEL 6 或者 7 机器复制内容。运行以下命令在 CentOS/RHEL 8 上使用 iptables 规则文件生成 nft 规则文件。
# iptables-restore-translate -f rules.iptables > rules.nft
- 在 CentOS/RHEL 8 机器上加载规则,确保系统上运行 nftables 服务。
# nft -f rules.nft ### load the rule via nft to nftables.
- 在 CentOS/RHEL 8 服务器中显示规则。
# nft list ruleset
现在可以看到规则已经从 CentOS/RHEL 6 或者 7 迁移到 CentOS/RHEL 8 服务器,也可以进行测试。
日期:2020-09-17 00:12:57 来源:oir作者:oir