树莓派 - 3 组网实验 - 备注

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方式比较省心。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值