Skip to main content
December 8, 2025
Question

Check and configure IP address on STM32H7 using LWIP

  • December 8, 2025
  • 2 replies
  • 85 views

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:

  1. If I enable DHCP, how can I find out the dynamically assigned IP of the STM32?

  2. 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?

  3. 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?

    This topic has been closed for replies.

    2 replies

    Super User
    December 8, 2025

    @DhanashreeB wrote:
    1. If I enable DHCP, how can I find out the dynamically assigned IP of the STM32?

    2. 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.

    1. Your DHCP server should have some UI through which you can see the addresses it's assigned
    2. That depends entirely upon your network setup

     

    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

    https://community.st.com/t5/stm32-mcus-products/lwip-ethernet-in-stm32h7-working-in-stm32cubeide-but-not-in-iar/m-p/748501/highlight/true#M267524

     

    Technical Moderator
    December 8, 2025

    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:

    mALLEm_0-1765194030438.png

    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.