This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using static address with DHCP server

Hi,

Keil Ethernet stack

I have trouble using static address when If I cannot find DHCP Server.
I enable Dynamic Host Configuration in Net_Config_ETH_0.h
I also specified my static ip address==192.168.0.100 and static Default Gateway =192.168.0.1.
Primary DNS Gateway =192.168.0.1.

I am connecting directly my Embedded device ethernet to PC.
My PC has static IP address = 192.168.0.1

If I disable Dynamic Host Configuration in Net_Config_ETH_0.h then it all works.

I thought If it cannot find DHCP server it will fallback back to using static DNS server which is my PC.

Kindly suggest what is wrong with my configuration. Does Keil Ethernet stack supports fallback?

Thanks,
Naeem

Parents Reply Children
  • I better use dynamic address assignment by DHCP server in all cases.

    If device is connected directly to Ethernet router which is connected out gateway PC Windows server IP Address=192.168.0.1 then all works then device gets assigned dynamic IP address.

    Windows 7/vista machine PC is not connect to any other network or WiFi network
    However If I connect my device directly to PC running Windows 7/vista machine. It does not have DHCP server on it then I need to use static IP address for Default Gateway.

    Kindly give me advise.

  • If the Windows machine isn't networked then you have no use for a gw address since the Win machine can't forward data.

    So what do you want to do on that local link?

    Note that IPv6 supports link-local IP numbers. But what is practical so much depends on what your device is expected to do. Or what the Win machine is expected to do with it. You might also have seen how MS (and then others) started to take random 169.x.x.x addresses if no DHCP IP gets assigned.

    The PC can communicate with your device without any IP assigned - the actual transfers aren't based on IP numbers but on hw (MAC) addresses. The IP is just there for routing and to look up the hw address of a device.

  • What meant was does Keil TCP/IP Stack supports AUTOIP if DHCP is enabled and not found then fall-back to use static IP Address.

    lwIP stack supports it.

    lwip.wikia.com/.../AUTOIP

    I have only 128k RAM. If I enable TCP/IP Debug. then my embedded device stops working.

  • But you do notice the huge difference of the Auto IP mode compared to your original post where you have set a hard-coded IP + GW to use if no DHCP server supplies an IP?

  • It works AUTOIP

    If I specified these addresses in Net_Config.h

    My Embedded device IP Address = 169.254.1.0
    The network mask = 255.255.0.0
    Default Gateway = 169.254.254.255

    Connect directly to Computer/Laptop running Windows vista/7

    I put my Windows machine IP Address = 169.254.254.255
    The network mask = 255.255.0.0

  • Are you really sure you understand AutoIP?

    What do you think this sentence means?
    "The default gateway is not assigned, because it is not known."

    How would that combine with your own statement:
    "Default Gateway = 169.254.254.255"

  • Hi,

    I know these functions to enable and disable DHCP which are "netDHCP_Enable" and "netDHCP_Disable".

    But I cannot find function to find current settings DHCP is enable or disable.

  • Errr ... it's your application that's controlling the state? and you can't figure out how to keep a record of what you set it to? OMG!

  • Hi,

    ok, I guess I need to keep DHCP is enable or disable setting in my variable.

    Thanks,
    Naeem

  • Since you would need some kind of state machine to decide when you want to enable or disable, it would be logical that the state machine also knows the current state so it knows what look for to decide if it should switch state.

  • Hi Per Westermark,

    I need to give user option to enable or disable DHCP and show current DHCP state on my GUI(Web page).

    When my embedded device will start. I think I can find if DHCP is enable or disable by callback

    netDHCP_Notify

    www.keil.com/.../group__ethernet__interface__callbacks.html

    Or I can always called DHCP enable in my setup

    and I will save current settings into my variable.

    When user change DHCP enable/disable from GUI(Web page). I can call netDHCP_Disable or netDHCP_Enable and save current state in my variable.

    Is this good solution?

    Thanks,
    Naeem

  • I need to give user option to enable or disable DHCP and show current DHCP state on my GUI(Web page).

    No, you don't. Because by the time anyone is even able to see that GUI, the issue will already be entirely moot. That would work about as well as putting the switch for the ceiling light in a place where you cannot find it without the ceiling light on.

  • I am still confused how to use Auto IP of ARM with Windows 7 .

    http://www.keil.com/forum/60356/

    It is working only If

    My Embedded device IP Address = 169.254.1.0
    The network mask = 255.255.0.0
    Default Gateway = 169.254.254.255
    Connect directly to Computer/Laptop running Windows vista/7
    I put my Windows machine IP Address = 169.254.254.255
    The network mask = 255.255.0.0

    My Embedded device IP Address is assigned IP address automatically above case.

    I do not want to use static IP addresses for Auto IP when DHCP is not found.

    I need to use automatically assign IP address for my My Embedded device and Windows 7 machine.

    Let me know how I can do it with example.

  • Why do you - in this thread - post a link pointing back to this very thread?

    M$ has documentation how to use APIPA for Windows 7. All you need to do is to say that the primary setting should have an IP automatically assigned. Then as alternative configuration you keep the default APIPA setting checked. 30 seconds with Google...

    But it is only relevant if you want to create a local island of non-connected machines. So friend A and friend B can connect their two computers together without any DHCP server.

    So it might be practical in a tent out in the wilderness. But most people have an existing network with at least a dirt-cheap router - and suddenly do not need APIPA.

    So - how have you ended up in a situation where you want your device and your Windows machine to be part of a local networking island? Remember that with APIPA you aren't expected to have a gateway, since the router that supplied that gateway would normally have been able to supply a working DHCP service, negating any need for APIPA.