2025-12-08 1:21 AM - last edited on 2025-12-08 1:35 AM by mƎALLEm
I’m currently working on an STM32 project with Ethernet connectivity and LwIP. I want to know the IP address of the STM32 while configuring the network settings in CubeIDE.
Here’s my setup:
STM32 is connected to a router via an Ethernet cable and my laptop is also connected to same router via wifi.
LwIP is being used as the TCP/IP stack.
In LwIP settings, there is an option to choose DHCP or Static IP.
My questions are:
If I enable DHCP, how can I find out the dynamically assigned IP of the STM32?
If I use a Static IP, what are the correct parameters to set (IP, Subnet Mask, Gateway) to ensure the STM32 is reachable from my PC?
Are there any tips or methods to quickly verify the STM32’s IP on the network, such as through serial print, ping, or a network scanner?
2025-12-08 2:44 AM
@DhanashreeB wrote:
If I enable DHCP, how can I find out the dynamically assigned IP of the STM32?
If I use a Static IP, what are the correct parameters to set (IP, Subnet Mask, Gateway) to ensure the STM32 is reachable from my PC?
Neither of these has anything specifically to do with STM32 - they are general IP networking questions.
To dive you better visibility on what's happening within your system, you should provide features to make such information available; eg, via a display or serial port.
LwIP already has a load of debug/diagnostic output features; eg,
Using the ITM console for printf redirects and LWIP debug messages
2025-12-08 3:46 AM - edited 2025-12-08 3:57 AM
Hello @DhanashreeB and welcome to the ST community,
1- If you enable DHCP you can see the acquired IP address in debug mode. I think you need to use struct netif.
If you take any of LWIP examples available in Cube, there is struct declaration called gnetif (global network interface - I think)
struct netif gnetif; /* network interface structure */
The acquired IP address is provided by ip_addr struct member.
2- For the static address, depending if your laptop is in Windows or Linux.
For example with windows, open the console and type ipconfig. that shows your IP parameters for your laptop:
As STM32 is connected on the same network as the laptop, use the same Subnet Mask and Gateway parameters and ensure you set a UNIQUE static IP (not used in the network).
3- For question 3 it's more linked to question 1. You can also use WireShark to debug the network transactions.
Hope that helps.