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

配置好静态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

  • 5
    点赞
  • 50
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
出现win10手动配置IP和自动IP169.254同时存在的问题,可能是因为存在网络连接出现问题的原因。在网络连接中,IP地址是一种核心的标识符,用于寻找网络中的其他设备。手动配置IP地址通常是指手动输入IP地址、子网掩码、网关等参数,来设置网络连接。而自动IP地址是在DHCP服务器出现问题时,操作系统会动态分配一个IP地址,保证网络连接的正常通信。当然,169.254.x.x的自动IP地址通常是非常不稳定的。 当手动配置IP地址与自动分配的IP地址在同一个子网时,可能会出现双重占用的情况,导致无法正常通信。建议先检查网络连接是否处于正常状态,并尝试重新启动网络设备和路由器,同时重启电脑也有可能解决这个问题。另外,尝试修改手动配置IP地址为与自动分配的IP地址不在同一个子网的地址,如更改子网掩码。如果问题依然存在,可以尝试使用其他设置方法,如使用静态IP。在网络连接中配置静态IP地址通常可以避免IP地址冲突的问题,但需要手动输入正确的IP地址、子网掩码、网关、DNS等信息。 总之,出现win10手动配置IP和自动IP169.254同时存在的问题,可能是由于网络连接出现问题导致的。需要尝试重新启动网络设备,并检查手动配置IP地址和自动分配的IP地址是否在同一个子网,如果是则更改手动配置IP地址和子网掩码。如果问题依然存在,可以尝试使用其他设置方法,如静态IP等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值