This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Gateway with euip and Static IP?

Hi there
My Concerto is working fine running a web page when I use DHCP and a router, so I can connect with the concerto from anywhere in or outside my network.
However, when I connect the Concerto directly to a wall socket with a Static IP (with no router) I only can connect with the Concerto from inside my network (but not from outside).
I've realized that uip doesn't allow setting up a Gateway (only allows Static IP + Subnet Mask) whereas a router using DHCP sends to the Concerto all the configuration (IP+subnet mask+gateway) and this way it works from everywhere inside or outside my network.


Is there any way to define a Gateway in the euip with Static IP?
When using uip with static IP is ti only possible get connection from inside my own network?

Thanks so much.

Dionisio

  • you should be able to modify the code to check if there is no gateway assigned by the DHCP then use the default (static) one.

    Best Regards

    Santosh

  • Thanks Santosh

    But my question is:

    Is it possible give a Gateway number to the Concerto when it is configured with Static IP (euip example)?

    When I use DHCP it works fine because the router sends the IP, Subnet Mask and Gateway to the Concerto.

    Nevertheless, when I use Static IP in the euip example (without router) there is not a field to provide a Gateway number so the concerto is unable to send packets to a external network.

    Dionisio

  • Dionisio,

    it should be possible to assign static values. Please trace the code to find the variable that stores the gateway address when using DHCP and try to initialize the same variable by hard coding the initialization value when you want to run static.

    Best Regards

    Santosh

  • OK, now it works!
    Thanks so much.

    Well, you have to open one free port in your router and redirect it to the number 80.
    Next, you can see the code used to get to work properly uip with Static IP (to make the Concerto accesible from an external network):

    // NEW:

    // At the beginning it is necessary setting up the IP for the default router:
    //-------------------------------------------------------------------------------------------
    // Default router
    #ifndef DEFAULT_ROUTER0
    #define DEFAULT_ROUTER0 192
    #endif

    #ifndef DEFAULT_ROUTER1
    #define DEFAULT_ROUTER1 168
    #endif

    #ifndef DEFAULT_ROUTER2
    #define DEFAULT_ROUTER2 1
    #endif

    #ifndef DEFAULT_ROUTER3
    #define DEFAULT_ROUTER3 1
    #endif
    //----------------------------------------------------------------------------------------

    .........
    .........
    .........


    // In the configuration:

    uip_init();

    #ifdef USE_STATIC_IP
    // Two steps are neccessary (see uip.h):
    // First we build the IP address shifting and adding the user defined bytes.
    // Next we copy an IP address from one place to another.

    // a) Set the IP address of this host:
    uip_ipaddr(ipaddr, DEFAULT_IPADDR0, DEFAULT_IPADDR1, DEFAULT_IPADDR2,
    DEFAULT_IPADDR3);
    uip_sethostaddr(ipaddr);
    ShowIPAddress(ipaddr);

    // b) Set the netmask:
    uip_ipaddr(ipaddr, DEFAULT_NETMASK0, DEFAULT_NETMASK1, DEFAULT_NETMASK2,
    DEFAULT_NETMASK3);
    uip_setnetmask(ipaddr);

    // NEW!!:
    // c) Set the default router's IP address:
    uip_ipaddr(ipaddr, DEFAULT_ROUTER0, DEFAULT_ROUTER1, DEFAULT_ROUTER2,
    DEFAULT_ROUTER3);
    uip_setdraddr(ipaddr);

    #else
    uip_ipaddr(ipaddr, 0, 0, 0, 0);// Shifts and add the bytes to build the IP address
    uip_sethostaddr(ipaddr);
    uip_ipaddr(ipaddr, 0, 0, 0, 0);// Shifts and add the bytes to build the IP address
    uip_setnetmask(ipaddr);
    #endif

    // That is it!