/etc/network/interfaces : ifup(man 8) 和 ifdown(man 8) 命令所使用的配置文件;
注释
`#’ 来注释行;不支持行尾注释,注释必须独占一行;
`\’ 用在行尾表示换行;
`\’ 用在行尾表示换行;
文件组成
文件由组成”iface”, “mapping”, “auto”, “allow-“, “source” and “source-directory” 关键字开始的小节组成。例如:
auto eth0
allow-hotplug eth1
allow-hotplug eth1
source interfaces.d/machine-dependent
source-directory interfaces.d
iface eth0 inet dhcp
iface eth0 inet6 auto
mapping eth1
script /usr/local/sbin/map-scheme
map HOME eth0-home
map WORK eth0-work
map HOME eth0-home
map WORK eth0-work
iface eth1-home inet static
address 192.168.1.2/24
gateway 192.168.1.1
up flush-mail
gateway 192.168.1.1
up flush-mail
iface eth1-work inet dhcp
auto
以 “auto” 开始的行,表示网卡会在执行 ifup -a 时启动。(系统启动脚本中使用了这个选项。)
网卡名要跟在 “auto” 后面。可以有多个 “auto” 部分。按照顺序,依次启动网卡。
网卡名要跟在 “auto” 后面。可以有多个 “auto” 部分。按照顺序,依次启动网卡。
allow-
以 “allow-” 开始的行,表示网卡会被各个子系统启动。This may be done using a command such as “ifup –allow=hotplug eth0 eth1”, which
will only bring up eth0 or eth1 if it is listed in an “allow-hotplug” line. Note that “allow-auto” 与 “auto” 同义.
will only bring up eth0 or eth1 if it is listed in an “allow-hotplug” line. Note that “allow-auto” 与 “auto” 同义.
no-auto-down
以 “no-auto-down” 开始的行,表示这些网口在执行 ifdown -a 时不关闭。
主要用在系统关机时,防止网口的关闭,比如 如果”根文件系统”是”网络文件系统” ,那就应该等到最后。
不过,仍然可以通过指定网口名的方式关闭;
主要用在系统关机时,防止网口的关闭,比如 如果”根文件系统”是”网络文件系统” ,那就应该等到最后。
不过,仍然可以通过指定网口名的方式关闭;
no-scripts
以 “no-scripts” 开始的行,表示这些接口在启动和关闭的时候不执行 /etc/network/if-*.d/ 下的脚本。
source & source-directory
“source” 关键字用于从其他文件引入内容。用法:source path/to/file。文件支持 Shell 通配符。(man 3 wordexp)
“source-directory” 关键字用于一次引入文件夹中多个文件,文件名要匹配: ^[a-zA-Z0-9_-]+$. 文件夹路径也可以使用shell通配符;
如果引入的文件或者文件夹不是绝对路径, 则相对于当前文件所在的文件夹。例如 如果是/etc/network/interfaces,那相对路径 则是 /etc/network.
目前(07/30/2016), network-manager 和 guessnet 不支持 “source-directory” .