1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Communication between client and server when DHCP is enabled

Discussion in 'Embedded' started by like2learn, Sep 28, 2010.

  1. like2learn

    like2learn Guest

    I have an embedded device which runs Linux and acts as a client, and a
    server at office. The IP address of the client is allocated by DHCP,
    so its IP address is actually

    variable. I would like to know what is the simpliest way to maintain
    the communication between client and server when DHCP is enabled.

    I once used socket many years ago to communicate between the client
    and the server. If I remember it right, I actually bypassed the
    dynamic IP issues by

    using the computer name to replace the IP address. Even the client is
    not at the same local network as the server, the scheme still worked.
    Correct me if my

    memory cheated me. Please let me know if socket is still the best
    solution for this kind of application involving DHCP?

    I also heard from someone that it is necessary to implement multicast
    discovery protocols named BONJOUR, but I don't think it is necessary,
    and I don't think

    it is a simple solution. What do you think?

    Thanks.
     
    like2learn, Sep 28, 2010
    #1
    1. Advertisements


  2. Typically the DHCP assigned IP address doesn't change for during a
    session, if it does, things tend to break.

    Anyway, it's usually a very bad idea to use IP addresses directly.
    They change. Usually you refer to DNS names ("www.google.com" and not
    "1.2.3.4"), and you use an API like GetHostByName() to translate that
    to an IP address that you use in a Connect(). Some networks provide
    non-DNS name resolutions, but those certainly don't generally work
    over the Internet (for example, Windows will resolve the machine name
    within a domain).

    A server's IP is usually fixed, so static DNS works. And in most
    cases it's the client connecting to the server, so it's only the
    client that needs to look up the server's IP address anyway. Dynamic
    DNS is commonly used when you don't have a static IP address, and you
    still need to handle inbound connections. The basic scheme is that
    you have a DDNS server someplace, and whenever the machine in question
    is a leased an IP address by DHCP, it reports that to the DDNS server,
    which then serves it via the usual DNS mechanisms. You can set some
    of that up yourself, or pay a DDNS vendor a few bucks to do it.
     
    robertwessel2, Sep 28, 2010
    #2
    1. Advertisements

  3. like2learn

    larwe Guest

    You really don't understand this application - whatever it is - well
    enough to implement it, based on the questions you're asking. Homework
    assignment?

    A device of this sort is almost certainly NOT on the Internet with a
    real IP address; it is sitting behind a router that is most likely
    doing NAT. So it doesn't have an IP address reachable from the outside
    world. There are ways around this, but the most common way of doing it
    is by opening an OUTBOUND socket from the node to home base, and then
    sending heartbeat traffic through periodically. This won't require any
    configuration change on the router beyond possibly opening a port
    (perhaps not even that, if you use a well-known port that is probably
    open for outbound connections already, e.g. 80).
     
    larwe, Sep 28, 2010
    #3
  4. like2learn

    like2learn Guest


    To open an OUTBOUND socket from the node to home base, do I need to
    know the Domain Name of the server in advance? Do I need a name server
    in place? I think most enterprise already have a name server in place.
    Thanks!
     
    like2learn, Sep 28, 2010
    #4

  5. Yes, although for small organizations it's almost always hosted
    externally, often by the ISP. Or any of dozens of DNS providers.
     
    robertwessel2, Sep 28, 2010
    #5
  6. like2learn

    Mel Guest

    The free service offered by dyndns.org is a possibility here.

    Mel.
     
    Mel, Sep 28, 2010
    #6
  7. like2learn

    like2learn Guest

    Thanks!
     
    like2learn, Sep 28, 2010
    #7
  8. like2learn

    D Yuniskis Guest

    Assuming the client *originates* the connection, you have nothing
    to do. It connects to the server at a well-known name/address/port.
    Server sees an incoming connection on that port and completes the
    open().

    If, OTOH, the server wants to originate the connection (!???), let
    the client register it's IP with a dynamic DNS using a well-known
    name and have the server resolve that name before it tries to
    connect.
     
    D Yuniskis, Sep 29, 2010
    #8
  9. like2learn

    Jack Guest

    On linux you just have to install avahi, it's the linux implementation
    of the zeroconf/bonjour protocol.

    Bye Jack
     
    Jack, Sep 30, 2010
    #9
  10. like2learn

    like2learn Guest

    Do I really need to install avahi on linux considering most router
    manufacturers already supported dynDNS in their equipments? BTW, to
    install avahi is just a simply download-and-run process, or the user
    is required to configure or modify the settings to make it work?
    Thanks.
     
    like2learn, Sep 30, 2010
    #10
  11. like2learn

    Tauno Voipio Guest

    Zeroconf is not the proper solution here. It is a
    local link protocol which does not work over routers.
     
    Tauno Voipio, Oct 1, 2010
    #11
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.