交换机作为DHCP server的IP分发过程(冲突的产生)

书接上回
我在交换机中新建了2个环回口
分别是
loopback0:30.179.1.1
loopback1:30.179.1.2
用来模拟2个终端。
此时,我再次接入PC去获取IP地址,这台PC是昨天获取过一次IP的,30.179.1.1。时间已经超过8小时租期。

按照昨天的理解,dhcp server会去发ICMP数据包去依次检测30.179.1.1以及30.179.1.2是否可用。很显然,环回口是可达的。因此,PC终端最终会获取到30.179.1.3这个IP。

事实和我预期的一样吗?

我们看下交换机的debugging信息。

*Sep 13 13:39:53:460 2024 Rack01-PRD-C-30.245 DHCPS/7/PACKET: From 0.0.0.0 port 68, interface Vlan-interface600
    Message type: REQUEST (1)
    Hardware type: 1, Hardware address length: 6
    Hops: 0, Transaction ID: 757040382
    Seconds: 0, Broadcast flag: 0
    Client IP address: 0.0.0.0   Your IP address: 0.0.0.0
    Server IP address: 0.0.0.0   Relay agent IP address: 0.0.0.0
    Client hardware address: a0ce-c8a2-0ef6
    Server host name: not configured
    Boot file name: not configured
    DHCP message type: DHCPDISCOVER (1)
*Sep 13 13:39:53:461 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: Receive a DHCPDISCOVER message from Vlan-interface600.
*Sep 13 13:39:53:461 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: Add a conflict IP 30.179.1.1.

当server收到第一个dhcpdiscover信息之后,它立马添加了一个conflict ip 30.179.1.1。
很显然,这个冲突的ip是PC和loopback0端口之间产生的。
那么也就是说,虽然PC的网卡目前还没有获取到IP,但是它依然携带了昨天获取到的IP信息,并且携带在这个discover的报文中。即便这个IP已经超过租期很久了。但旧的信息依然存在。
也许这就是交换机产生大量的conflict的原因之一。

看下第一个discover报文
在这里插入图片描述
option 50中携带了上一次获取到的IP地址。这个信息,一直在网卡中保存着。

我们往下看,server直接发了一个30.179.1.3的ICMP报文,并没有像我理解的那样,需要发30.179.1.1和30.179.1.2的ICMP。也就是交换机直接知道了有这2个IP的存在。这是为什么?
难道是因为我是直接在交换机上面创建的环回口?交换机默认直接知道了?

*Sep 13 13:39:53:462 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: Send an ICMP echo request to 30.179.1.3.
*Sep 13 13:39:54:059 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: Send a DHCPOFFER message on Vlan-interface600.
*Sep 13 13:39:54:061 2024 Rack01-PRD-C-30.245 DHCPS/7/PACKET: To 30.179.1.3 port 68, interface Vlan-interface600
    Message type: REPLY (2)
    Hardware type: 1, Hardware address length: 6
    Hops: 0, Transaction ID: 757040382
    Seconds: 0, Broadcast flag: 0
    Client IP address: 0.0.0.0   Your IP address: 30.179.1.3
    Server IP address: 0.0.0.0   Relay agent IP address: 0.0.0.0
    Client hardware address: a0ce-c8a2-0ef6
    Server host name: not configured
    Boot file name: not configured
    DHCP message type: DHCPOFFER (2)

下面就是正常的流程,交换机连续收到3次discover报文,并连续给了3个offer。直到收到了终端的request报文,最后给出ACK。

*Sep 13 13:39:57:432 2024 Rack01-PRD-C-30.245 DHCPS/7/PACKET: From 0.0.0.0 port 68, interface Vlan-interface600
    Message type: REQUEST (1)
    Hardware type: 1, Hardware address length: 6
    Hops: 0, Transaction ID: 757040382
    Seconds: 768, Broadcast flag: 0
    Client IP address: 0.0.0.0   Your IP address: 0.0.0.0
    Server IP address: 0.0.0.0   Relay agent IP address: 0.0.0.0
    Client hardware address: a0ce-c8a2-0ef6
    Server host name: not configured
    Boot file name: not configured
    DHCP message type: DHCPDISCOVER (1)
*Sep 13 13:39:57:433 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: Receive a DHCPDISCOVER message from Vlan-interface600.
*Sep 13 13:39:57:434 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: Send an ICMP echo request to 30.179.1.3.
*Sep 13 13:39:57:959 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: Send a DHCPOFFER message on Vlan-interface600.
*Sep 13 13:39:57:960 2024 Rack01-PRD-C-30.245 DHCPS/7/PACKET: To 30.179.1.3 port 68, interface Vlan-interface600
    Message type: REPLY (2)
    Hardware type: 1, Hardware address length: 6
    Hops: 0, Transaction ID: 757040382
    Seconds: 768, Broadcast flag: 0
    Client IP address: 0.0.0.0   Your IP address: 30.179.1.3
    Server IP address: 0.0.0.0   Relay agent IP address: 0.0.0.0
    Client hardware address: a0ce-c8a2-0ef6
    Server host name: not configured
    Boot file name: not configured
    DHCP message type: DHCPOFFER (2)
*Sep 13 13:40:05:902 2024 Rack01-PRD-C-30.245 DHCPS/7/PACKET: From 0.0.0.0 port 68, interface Vlan-interface600
    Message type: REQUEST (1)
    Hardware type: 1, Hardware address length: 6
    Hops: 0, Transaction ID: 757040382
    Seconds: 3072, Broadcast flag: 0
    Client IP address: 0.0.0.0   Your IP address: 0.0.0.0
    Server IP address: 0.0.0.0   Relay agent IP address: 0.0.0.0
    Client hardware address: a0ce-c8a2-0ef6
    Server host name: not configured
    Boot file name: not configured
    DHCP message type: DHCPDISCOVER (1)
*Sep 13 13:40:05:903 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: Receive a DHCPDISCOVER message from Vlan-interface600.
*Sep 13 13:40:05:904 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: Send an ICMP echo request to 30.179.1.3.
*Sep 13 13:40:06:459 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: Send a DHCPOFFER message on Vlan-interface600.
*Sep 13 13:40:06:461 2024 Rack01-PRD-C-30.245 DHCPS/7/PACKET: To 30.179.1.3 port 68, interface Vlan-interface600
    Message type: REPLY (2)
    Hardware type: 1, Hardware address length: 6
    Hops: 0, Transaction ID: 757040382
    Seconds: 3072, Broadcast flag: 0
    Client IP address: 0.0.0.0   Your IP address: 30.179.1.3
    Server IP address: 0.0.0.0   Relay agent IP address: 0.0.0.0
    Client hardware address: a0ce-c8a2-0ef6
    Server host name: not configured
    Boot file name: not configured
    DHCP message type: DHCPOFFER (2)
*Sep 13 13:40:06:467 2024 Rack01-PRD-C-30.245 DHCPS/7/PACKET: From 0.0.0.0 port 68, interface Vlan-interface600
    Message type: REQUEST (1)
    Hardware type: 1, Hardware address length: 6
    Hops: 0, Transaction ID: 757040382
    Seconds: 3072, Broadcast flag: 0
    Client IP address: 0.0.0.0   Your IP address: 0.0.0.0
    Server IP address: 0.0.0.0   Relay agent IP address: 0.0.0.0
    Client hardware address: a0ce-c8a2-0ef6
    Server host name: not configured
    Boot file name: not configured
    DHCP message type: DHCPREQUEST (3)
*Sep 13 13:40:06:468 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: Receive a DHCPREQUEST message for 30.179.1.3 from Vlan-interface600; The server identifier is 30.179.1.245.
*Sep 13 13:40:06:469 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: The client selected the local server.
*Sep 13 13:40:06:470 2024 Rack01-PRD-C-30.245 DHCPS/7/EVENT: Send a DHCPACK message on Vlan-interface600.
*Sep 13 13:40:06:475 2024 Rack01-PRD-C-30.245 DHCPS/7/PACKET: To 30.179.1.3 port 68, interface Vlan-interface600
    Message type: REPLY (2)
    Hardware type: 1, Hardware address length: 6
    Hops: 0, Transaction ID: 757040382
    Seconds: 3072, Broadcast flag: 0
    Client IP address: 0.0.0.0   Your IP address: 30.179.1.3
    Server IP address: 0.0.0.0   Relay agent IP address: 0.0.0.0
    Client hardware address: a0ce-c8a2-0ef6
    Server host name: not configured
    Boot file name: not configured
    DHCP message type: DHCPACK (5)

以下是PC终端的报文显示
在这里插入图片描述
与交换机呈现的一致,分别是3个discover和3次offer。
最终,PC如愿获取到了30.179.1.3。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值