环境:ubuntu 10.10
方针:装备网卡启动时加载iptables规矩
网络上搜到的各种操作:
sh -c iptables-save > /etc/iptables.rules
vi /etc/network/interfaces
## 方针网卡下添加一条指令
## pre-up iptables-restore /etc/iptables.rules
可是,经测验发现。重启后这些装备会丢掉,检查这个文件头会发现。
# This configuration file is auto-generated.
# WARNING: Do not edit this file, your changes will be lost.
# Please create/edit /etc/network/interfaces.head and /etc/network/interfaces.tail instead,
# their contents will be inserted at the beginning and at the end
# of this file, respectively.
#
# NOTE: it is NOT guaranteed that the contents of /etc/network/interfaces.tail
# will be at the very end of this file.
文件写得很清晰,/etc/network/interfaces是主动生成的。假如咱们需求自定义装备,那就创立/etc/network/interfaces.head或/etc/network/interfaces.tail。其间/etc/network/interfaces.tail并不引荐。
以下是一个示例:
auto venet0:0
iface venet0:0 inet static
address 184.22.224.125
netmask 255.255.255.0
pre-up iptables-restore /etc/iptables.rules