---
title: "W6100 DHCP 관련하여 문의 드립니다."
url: "https://maker.wiznet.io/forum/14856"
markdown_url: "https://maker.wiznet.io/forum/14856/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "coollhc"
created: "2023-03-31T08:29:56+09:00"
last_activity: "2023-04-01T11:08:19+09:00"
language: "ko"
views: 285
replies: 3
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W6100 DHCP 관련하여 문의 드립니다.

## Question

Asked by coollhc on 2023-03-31 in Ethernet Chips.

질문 1:
아래 DHCP 초기화 함수 중 DHCPv4_CHADDR[0] ~ DHCPv4_CHADDR[5] 값이 고정되어 있는데
만약 공유기 1대에 w6100을 사용한 여러대가 동시에 전원이 켜지고, DHCP를 요청하게 되어도 문제가 없나요?

void DHCPv4_init(uint8_t s, uint8_t * buf)
{
uint8_t zeroip[4] = {0,0,0,0};
getSHAR(DHCPv4_CHADDR);
if((DHCPv4_CHADDR[0] | DHCPv4_CHADDR[1] | DHCPv4_CHADDR[2] | DHCPv4_CHADDR[3] | DHCPv4_CHADDR[4] | DHCPv4_CHADDR[5]) == 0x00)
{
// assigning temporary mac address, you should be set SHAR before call this function.
DHCPv4_CHADDR[0] = 0x00;
DHCPv4_CHADDR[1] = 0x08;
DHCPv4_CHADDR[2] = 0xdc;
DHCPv4_CHADDR[3] = 0x00;
DHCPv4_CHADDR[4] = 0x00;
DHCPv4_CHADDR[5] = 0x00;
setSHAR(DHCPv4_CHADDR);
}

```
DHCPV4_SOCKET = s; // SOCK_DHCP
pDHCPv4MSG = (RIP_MSG*)buf;
DHCPV4_XID = 0x12345678;
{
	DHCPV4_XID += DHCPv4_CHADDR[3];
	DHCPV4_XID += DHCPv4_CHADDR[4];
	DHCPV4_XID += DHCPv4_CHADDR[5];
	DHCPV4_XID += (DHCPv4_CHADDR[3] ^ DHCPv4_CHADDR[4] ^ DHCPv4_CHADDR[5]);
}

// WIZchip Netinfo Clear
setSIPR(zeroip);
setGAR(zeroip);

reset_DHCPv4_timeout();
dhcpv4_state = STATE_DHCPV4_INIT;
```

}

질문 2:
공유기에 접속한 이후 IP임대시간 만료가 되면 어떻게 처리해야 하는지 궁금합니다.
DHCPv4_run() 을 주기적으로 실행하여 확인을 해야 하나요? 아니면 다른 방법이 있나요?
혹시 IP 임대시간 만료를 확인할 수 있는 예제가 있을까요?

항상 감사합니다.

## Replies

### Reply 1 by Eugeny, 2023-03-31

Answer 1 in the code:

```
// assigning temporary mac address, you should be set SHAR before call this function.
```

If this code executes (due to the `if` condition being true) every device with this MAC address will receive same IP address.

Answer 2: this goes beyond the chip functionality and is defined in the DHCP protocol. In general you are right, when lease expires you must perform DHCP again. If you do not perform it current device will continue working, until DHCP accidentally leases this IP address to another network node.

### Reply 2 by coollhc, 2023-04-01 (in reply to reply 1)

Question 1:
Does each w6100 device need to request a different MAC address when running DHCP?

Question 2:
We found a way
Analyze the DHCP behavior and protocol

[Edward'sLabs – 31 May 16](https://openstory.tistory.com/39)

![](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/6/61cbad8ea13aa4379d4e1a93b4232025aaa4f281.png)

### [DHCP 전체 동작 과정 및 프로토콜 분석 !](https://openstory.tistory.com/39)

이번 시간에는 저번 강좌와 이어서 DHCP Protocol의 전체 동작 과정과 DHCP의 구동 Protocol에 대한 설명을 진행하겠습니다.저번 강좌에서 DHCP란, "IP를 할당하여 주는 프로토콜이다." 라고 언급하였습니다. 이것이 DHCP의 가장 큰 존재목적이긴 하지만 부가적인 설명이 설명이 필요하다고 판단하여 DHCP에 대한 추가적인 설명을 진행하겠습니다.DHCP는 네트워크 상에서 IP 주소를 중앙에서 관리하고 할당해줄 수 있도록 해주는...

w5500_EVB DHCP Client code

![](https://github.githubassets.com/favicons/favicon.svg) [github.com](https://github.com/Wiznet/W5500_EVB/tree/master/w5500evb_internet_dhcp_client)

### [W5500_EVB/w5500evb_internet_dhcp_client at master · Wiznet/W5500_EVB](https://github.com/Wiznet/W5500_EVB/tree/master/w5500evb_internet_dhcp_client)

[master/w5500evb_internet_dhcp_client](https://github.com/Wiznet/W5500_EVB/tree/master/w5500evb_internet_dhcp_client)

W5500-EVB Library and Examples. Contribute to Wiznet/W5500_EVB development by creating an account on GitHub.

### Reply 3 by Eugeny, 2023-04-01

![](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/48.png) coollhc:

> Does each w6100 device need to request a different MAC address when running DHCP?

See [here](https://en.wikipedia.org/wiki/MAC_address).

---

Source: https://maker.wiznet.io/forum/14856
