ZEROCONF是什么
http://blog.chinaunix.net/uid-20644632-id-2172223.html有一台CentOS 5.5的server(网段是172.21.73.0),查看它的路由表是发现一个奇怪的项目:[shengkui@APP-SERVER ~]$ routeKernel IP routing tableDestination Gateway Genmas
http://blog.chinaunix.net/uid-20644632-id-2172223.html
有一台CentOS 5.5的server(网段是172.21.73.0),查看它的路由表是发现一个奇怪的项目:
- [shengkui@APP-SERVER ~]$ route
- Kernel IP routing table
- Destination Gateway Genmask Flags Metric Ref Use Iface
- 172.21.73.0 * 255.255.255.0 U 0 0 0 eth0
- 169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
- default 172.21.73.253 0.0.0.0 UG 0 0 0 eth0
居然有一个 169.254.0.0 的项目,这个路由表项是干什么的,从哪里来?
经过查找资料,终于明白了,这个项目是: Zero Configuration Network (ZEROCONF)。ZEROCONF又被叫做 IPv4 Link-Local (IPv4LL)和 Automatic Private IP Addressing (APIPA)。它是一个动态配置协议,系统可以通过它来连接到网络。
很多Linux发行版都默认安装该服务,当系统无法连接DHCP server的时候,就会尝试通过ZEROCONF来获取IP。
在CentOS5.x中,ZEROCONF的路由项是在下面的启动脚本被添加到路由表的。
/etc/init.d/network会调用 /etc/sysconfig/network-scripts/ifup-eth 脚本,ifup-eth 脚本会添加ZEROCONF路由项,代码如下:
- # Add Zeroconf route.
- if [ -z "${NOZEROCONF}" -a "${ISALIAS}" = "no" -a "${REALDEVICE}" != "lo" ]; then
- ip route replace 169.254.0.0/16 dev ${REALDEVICE}
- fi
那有没有办法禁用ZEROCONF呢?
可以通过在 "/etc/sysconfig/network" 文件中增加一行“NOZEROCONF=yes”来达到这个目的。
其实,给 NOZEROCONF 赋任意值都是同样的效果,从上面的代码就可以看出,它只检测 NOZEROCONF 是否为空。
当然,修改完 "/etc/sysconfig/network" 之后,必须重启网络才能生效:/etc/init.d/network restart
在Linux下面还有一个daemon与Zeroconf相关,就是 AVAHI,详细信息参考:http://avahi.org。
Zeroconf is a program that you can use to claim IPv4 link-local addresses. IPv4 link-local addresses are useful if you wish to setup ad-hocnetworking between devices without the involvement of a either a DHCPserver or your (very busy) network administrator.
These addresses are allocated from the 169.254.0.0/16 address rangeand are normally attached to each Ethernet device in your computer.Addresses are assigned randomly by each host and, in case ofcollision, both hosts (are supposed to) renumber.
Coupled with DNS ServiceDiscovery (DNS-SD), IPv4 link-local addresses allow you to connectprinters, cameras and, of course, other computers together and thingswill "Just Work". All without any centralised configuration (e.g. aDNS or DHCP server).
Zeroconf was written to have minimal dependancies, be very small andbe reasonably portable. Additionally it should be very simple to dropinto place for any Linux distribution.
更多推荐
所有评论(0)