cancel
Showing results for 
Search instead for 
Did you mean: 

Dual IP Support on single Ethernet interface using lwip

AGupt.12
Associate II

I am using LWIP stack on my STM32F429 Nucleo board. Since this board has only one Ethernet interface i want to get Dual IP Support ( Static and Dynamic ) on the same interface. 

I did find certain community threads that explains some ways to achieve this by doing modifications in lwip stack but is there any document version or steps that i can follow to get Dual IP Support without much changes in lwip stack.

Thank you for help.

4 REPLIES 4
Piranha
Chief II

That is not what people would typically understand with "dual IP". You don't need to modify lwIP as it already supports all APIs that are necessary for this. Just set manual IP or start DHCP in your code. When necessary, stop DHCP and set manual IP.

And be warned:

https://community.st.com/s/question/0D50X0000BOtfhnSQB/how-to-make-ethernet-and-lwip-working-on-stm32

AGupt.12
Associate II

Hello Piranha,

Here with Dual Ip i mean to support multiple static IP ( two or more ) on single hardware etherent interface using lwip.

For example: I want to have 192.168.1.130 and 192.168.1.131 IP address for my device but on a single ethernet interface. If i do ping test i should be able to get response from both the IPs.

Similarly i also wants to have dual dynamic IPs for my device using a single ethernet interface.

Piranha
Chief II

In that case you have to make multiple struct netif logical interfaces and make the code use a single Ethernet hardware interface behind those. It requires some work but it's possible. 🙂

hello
@AGupt.12did you get it ?
@Piranha:
I tried to implement the solution like this but it doesn't work:

    lwip_init();

    // Add the first logical interface with its IP configuration
    IP4_ADDR(&netif_ipaddr, 192, 168, 0, 102);
    IP4_ADDR(&netif_netmask, 255, 255, 255, 0);
    IP4_ADDR(&netif_gw, 192, 168, 0, 100);



    // Add the second logical interface with its IP configuration
    IP4_ADDR(&netif2_ipaddr, 192, 168, 0, 111);
    IP4_ADDR(&netif2_netmask, 255, 255, 255, 0);
    IP4_ADDR(&netif2_gw, 192, 168, 0, 100);
    


    netif_add(&netif, &netif_ipaddr, &netif_netmask, &netif_gw, &enet_config, EXAMPLE_NETIF_INIT_FN, ethernet_input);
    netif_set_up(&netif);


    netif_add(&netif2, &netif2_ipaddr, &netif2_netmask, &netif2_gw, &enet_config, EXAMPLE_NETIF_INIT_FN, ethernet_input);
    netif_set_up(&netif2);



    while (1)
    {
        /* Poll the driver, get any outstanding frames */
        ethernetif_input(&netif);
        ethernetif_input(&netif2);

        sys_check_timeouts(); /* Handle all system timeouts for all core protocols */
    }