Ubuntu10.10网卡配置文件重启失效

环境: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

Ubuntu10.10网卡配置文件重启失效