Environment: Ubuntu 10.10
Goal: Configure the load iptables rule when the NIC starts
The various operations found on the network:
Sh-c "Iptables-save >/etc/iptables.rules"
# # Add a command under the target card
# # pre-up Iptables-restore </etc/iptables.rules
However, it was found by test. These configurations will be lost after the reboot, and you will see this file header.
# This configuration the file is auto-generated.
# Warning:do Not edit this file, your changes would be lost.
# please create/edit/etc/network/interfaces.head And/etc/network/interfaces.tail instead,
# their contents'll be inserted at the beginning
# of this file, respectively.
# Note:it is isn't guaranteed that the contents Of/etc/network/interfaces.tail
# would be in the very end of this file.
The file is written very clearly and the/etc/network/interfaces is automatically generated. If we need a custom configuration, create/etc/network/interfaces.head or/etc/network/interfaces.tail. Which/etc/network/interfaces.tail is not recommended.
Here's an example:
Iface venet0:0 inet Static
Pre-up Iptables-restore </etc/iptables.rules