永久保存 iptables 配置

Saj*_*gar 1 ubuntu iptables

如何永久保存此配置?

sudo iptables -t nat -A POSTROUTING -s 10.10.0.0/16 -o eth0 -j MASQUERADE

Mar*_*ich 5

您需要将该命令添加到在启动时执行的文件中,例如添加到/etc/rc.local. 您还可以删除sudo前缀,因为root无论如何都会执行此文件。

您还可以安装和使用该软件包iptables-persistent

martin@dogmeat ~ % aptitude show iptables-persistent
Package: iptables-persistent             
State: not installed
Version: 0.5.7
Priority: optional
Section: universe/admin
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: all
Uncompressed Size: 62.5 k
Depends: iptables, lsb-base, debconf (>= 0.5) | debconf-2.0
Description: boot-time loader for iptables rules
 This package provides a system startup script that restores iptables rules from a configuration file. 

 Since this is aimed at experienced administrators, there is no configuration wizard.
Run Code Online (Sandbox Code Playgroud)

根据文档,它从/etc/iptables/rules.