树莓派

来源:互联网 发布:最新美化照片软件 编辑:程序博客网 时间:2024/06/05 03:17

1. interfaces中参数的含义

参见:https://unix.stackexchange.com/questions/128439/good-detailed-explanation-of-etc-network-interfaces-syntax


layer 2 options:

auto – Start the interface(s) at boot. That’s why the lo interface uses this kind of linking configuration.

allow-hotplug – Start the interface when a "hotplug" event is detected. In the real world, this is used in the same situations as auto but the difference is that it will wait for an event like "being detected by udev hotplug api" or "cable linked". 


Layer 3 options:

inet static – Defines a static IP address.

inet manual – Does not define an IP address for an interface. Generally used by interfaces that are bridge or aggregation members.

inet dhcp – Acquire IP address through DHCP protocol.


2. auto与allow-hotplug的区别

参见:http://blog.csdn.net/xkq_lyx/article/details/17079849

/etc/network/interfaces文件中一般用auto或者allow-hotplug来定义接口的启动行为。

auto
在系统启动的时候启动网络接口,无论网络接口有无连接(插入网线),如果该接口配置了DHCP,则无论有无网线,系统都会去执行DHCP,如果没有插入网线,则等该接口超时后才会继续。

allow-hotplug
只有当内核从该接口检测到热插拔事件后才启动该接口。如果系统开机时该接口没有插入网线,则系统不会启动该接口,系统启动后,如果插入网线,系统会自动启动该接口。也就是将网络接口设置为热插拔模式。

一般修改了网络配置文件后,会用以下命令重新启动网络
# /etc/init.d/networking restart
但从squeeze开始,此命令会有如下提示:
Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces … (warning).
Reconfiguring network interfaces…done.

如果设置接口为auto,虽然会有如此提示,但接口仍然会正确的启动。
如果接口设置为allow-hotplug则没有这么走运了,网络接口不会正确启动。这种情况下必须使用如下命令启动网络接口:
#ifup <interface_name>

看来大多数情形下,网络接口还是用auto方式比较省心。