博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZEROCONF是什么
阅读量:2189 次
发布时间:2019-05-02

本文共 2038 字,大约阅读时间需要 6 分钟。

有一台CentOS 5.5的server(网段是172.21.73.0),查看它的路由表是发现一个奇怪的项目:

  1. [shengkui@APP-SERVER ~]$ route
  2. Kernel IP routing table
  3. Destination Gateway Genmask Flags Metric Ref Use Iface
  4. 172.21.73.0 * 255.255.255.0 U 0 0 0 eth0
  5. 169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
  6. 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路由项,代码如下:
  1. # Add Zeroconf route.
  2. if [ -z "${NOZEROCONF}" -a "${ISALIAS}" = "no" -a "${REALDEVICE}" != "lo" ]; then
  3. ip route replace 169.254.0.0/16 dev ${REALDEVICE}
  4. 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-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.

转载地址:http://cduub.baihongyu.com/

你可能感兴趣的文章
简单封装FMDB操作sqlite的模板
查看>>
iOS开发中Instruments的用法
查看>>
iOS常用宏定义
查看>>
什么是ActiveRecord
查看>>
有道词典for mac在Mac OS X 10.9不能取词
查看>>
关于“团队建设”的反思
查看>>
利用jekyll在github中搭建博客
查看>>
Windows7中IIS简单安装与配置(详细图解)
查看>>
linux基本命令
查看>>
BlockQueue 生产消费 不需要判断阻塞唤醒条件
查看>>
强引用 软引用 弱引用 虚引用
查看>>
数据类型 java转换
查看>>
"NetworkError: 400 Bad Request - http://172.16.47.117:8088/rhip/**/####t/approval?date=976
查看>>
mybatis 根据 数据库表 自动生成 实体
查看>>
win10将IE11兼容ie10
查看>>
checkbox设置字体颜色
查看>>
第一篇 HelloWorld.java重新学起
查看>>
ORACLE表空间扩张
查看>>
orcal 循环执行sql
查看>>
web.xml配置监听器,加载数据库信息配置文件ServletContextListener
查看>>