配置静态IP后多出个169.254段的IP

阅读: 评论:0

配置静态IP后多出个169.254段的IP

配置静态IP后多出个169.254段的IP

目录

  • 配置好静态ip后出现如下状况
  • 原因--APIPA
  • 如何解决
      • 如上所说临时解决可关闭此功能
      • 解决
      • 模拟arp回应
    • linux

配置好静态ip后出现如下状况

物理地址. . . . . . . . . . . . . : 00-22-64-55-76-8F
DHCP 已启用 . . . . . . . . . . . : 否
自动配置已启用. . . . . . . . . . : 是
自动配置 IPv4 地址 . . . . . . . : 169.254.1.193(首选)
子网掩码 . . . . . . . . . . . . : 255.255.0.0
IPv4 地址 . . . . . . . . . . . . : 192.168.1.123(复制)
子网掩码 . . . . . . . . . . . . : 255.255.255.0
默认网关. . . . . . . . . . . . . : 192.168.1.1
TCPIP 上的 NetBIOS . . . . . . . : 已启用

原因–APIPA

Automatic Private IP Addressing (APIPA) is a DHCP fail-safe that protects a computer system from failure by invoking a standby mechanism for local Internet Protocol version 4 (IPv4) networks supported by Microsoft Windows. With APIPA, DHCP clients can obtain IP addresses even when DHCP servers are not functional. APIPA exists in all modern versions of Windows, including Windows 10.
How APIPA Works
Networks that are set up for dynamic addressing rely on a DHCP server to manage the pool of available local IP addresses. When a Windows client device attempts to join the local network, it contacts the DHCP server to request its IP address. If the DHCP server stops functioning, a network glitch interferes with the request, or some issue occurs on the Windows device, this process can fail.
When the DHCP process fails, Windows automatically assigns an IP address from the private range, which is 169.254.0.1 to 169.254.255.254. Using Address Resolution Protocol (ARP), clients verify that the chosen APIPA address is unique on the network before they use it . Clients then check back with the DHCP server at periodic intervals—usually every five minutes—and update their addresses automatically when the DHCP server is able to service requests.
When you start a computer running Windows Vista, for example, it waits for only six seconds for a DHCP server before using an IP from the APIPA range. Earlier versions of Windows look for a DHCP server for as long as three minutes.
All APIPA devices use the default network mask 255.255.0.0, and all reside on the same subnet.
APIPA is enabled by default in Windows whenever the PC network interface is configured for DHCP. This option is called autoconfiguration in Windows utilities such as ipconfig. A computer administrator can disable the feature by editing the Windows Registry and setting the following key value to 0:
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/TcpipParameters/IPAutoconfigurationEnabled
Network administrators and experienced computer users recognize that failures in the DHCP process indicate network troubleshooting is needed to identify and resolve the issues that are preventing DHCP from working properly.

原因:
1.无论你的网卡是否设置为DHCP,APIPA都默认开启,当自动获取IP无法得到dhcp服务器的回应,会给它自动分配一个在169.254.0.1到169.254.255.254间的地址,防止网络冲突。(DHCP获取失败后,同样要发送ARP请求查看冲突,此时发送ip为0)
2. 即使手动设置了ip,任何接入网络的网卡接口首先会发送一个自身IP的ARP询问请求,确认网络中没有相同IP,保正IP唯一性,如果收不到arp回应则ok,如果收到有相同IP,则报IP冲突并自动分配一个IP.(此时发送的arp请求中发送ip和请求ip相同)

如何解决

如上所说临时解决可关闭此功能

  1. 打开注册表regedit
  2. 编辑项目,若未找到则新建选择 DWORD 值
    HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/TcpipParameters/IPAutoconfigurationEnabled
  3. 设置该值为0,退出
  4. 网卡禁用重启生效

解决

1 . 查找是否有相同IP
2. 抓包看是否arp询问请求回应是否正确

模拟arp回应

    struct ethernet_arp_packet *const parph = (struct ethernet_arp_packet *)pbuf;if(ntohs(parph->arp.hdr.ar_hrd)==ARPHRD_ETHER && ntohs(parph->arp.hdr.ar_pro)==ETH_P_IP&& ntohs(parph->arp.hdr.ar_op)==ARPOP_REQUEST){if(parph->arp.hdr.ar_hln==6&&parph->arp.hdr.ar_pln==IPVERSION)//ipv4{unsigned int ipval = *((unsigned int*)parph->arp.ip_sender);//ip_sender==0:dhcp arp, ip_sender==ip_target:ask whether there`s a same ip in network?if(0==ipval||0==memcmp(parph->arp.ip_sender,parph->arp.ip_target,4))return;arp_reply(ETH_NAME,rsk.h_src,parph->arp.mac_sender,rsk.h_src,parph->arp.ip_target,parph->arp.mac_sender,parph->arp.ip_sender);}}

linux

zeroconf
connman

本文发布于:2024-01-27 22:46:41,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/17063668283105.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:多出   静态   IP
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23