Dynamically assign IP based on MAC - Networking

This is a discussion on Dynamically assign IP based on MAC - Networking ; Hi all, I understand how to assign static IP addresses with DHCP based on MAC. But here's what I'd like to do: I'd like to dynamically assign an IP address to a MAC based on some rule (the rule really ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Dynamically assign IP based on MAC

  1. Dynamically assign IP based on MAC

    Hi all,

    I understand how to assign static IP addresses with DHCP
    based on MAC. But here's what I'd like to do: I'd like to dynamically
    assign an IP address to a MAC based on some rule (the rule really
    is: look up this MAC in a table and give the IP address from that
    table,
    unless it doesn't exist, in which case assign a new one and enter it
    into the table). In other words, you'll get the same IP every time
    you
    connect with the same MAC, but we don't know all MACs beforehand.


  2. Re: Dynamically assign IP based on MAC

    DEBEDb wrote:
    > Hi all,
    >
    > I understand how to assign static IP addresses with DHCP
    > based on MAC. But here's what I'd like to do: I'd like to dynamically
    > assign an IP address to a MAC based on some rule (the rule really
    > is: look up this MAC in a table and give the IP address from that
    > table,
    > unless it doesn't exist, in which case assign a new one and enter it
    > into the table). In other words, you'll get the same IP every time
    > you
    > connect with the same MAC, but we don't know all MACs beforehand.
    >


    IME DHCP tends to give the same IP to the same machine unless it
    gets starved for addresses and reuses it. Not sure what the underlying
    rules are though.

  3. Re: Dynamically assign IP based on MAC

    Joe Beanfish wrote:
    > DEBEDb wrote:
    >
    >> Hi all,
    >>
    >> I understand how to assign static IP addresses with DHCP
    >> based on MAC. But here's what I'd like to do: I'd like to dynamically
    >> assign an IP address to a MAC based on some rule (the rule really
    >> is: look up this MAC in a table and give the IP address from that table,
    >> unless it doesn't exist, in which case assign a new one and enter it
    >> into the table). In other words, you'll get the same IP every time you
    >> connect with the same MAC, but we don't know all MACs beforehand.
    >>

    >
    > IME DHCP tends to give the same IP to the same machine unless it
    > gets starved for addresses and reuses it. Not sure what the underlying
    > rules are though.


    The request for the old address comes from the client. The
    DHCP server usually grants it, unless it it already leased
    to somewhere else.

    --

    Tauno Voipio
    tauno voipio (at) iki fi

  4. Re: Dynamically assign IP based on MAC

    Tauno Voipio wrote:
    > Joe Beanfish wrote:
    >> DEBEDb wrote:
    >>
    >>> Hi all,
    >>>
    >>> I understand how to assign static IP addresses with DHCP
    >>> based on MAC. But here's what I'd like to do: I'd like to dynamically
    >>> assign an IP address to a MAC based on some rule (the rule really
    >>> is: look up this MAC in a table and give the IP address from that table,
    >>> unless it doesn't exist, in which case assign a new one and enter it
    >>> into the table). In other words, you'll get the same IP every time you
    >>> connect with the same MAC, but we don't know all MACs beforehand.
    >>>

    >>
    >> IME DHCP tends to give the same IP to the same machine unless it
    >> gets starved for addresses and reuses it. Not sure what the underlying
    >> rules are though.

    >
    > The request for the old address comes from the client. The
    > DHCP server usually grants it, unless it it already leased
    > to somewhere else.
    >


    Even after having been turned off?

  5. Re: Dynamically assign IP based on MAC

    Hello,

    Joe Beanfish a écrit :
    >>
    >> The request for the old address comes from the client. The
    >> DHCP server usually grants it, unless it it already leased
    >> to somewhere else.

    >
    > Even after having been turned off?


    That's what lease files are for.

  6. Re: Dynamically assign IP based on MAC

    On Jan 31, 2:28 pm, Joe Beanfish wrote:
    > Even after having been turned off?


    A well-behaved server (e.g, ISC) will remember the IP it last gave the
    client and offer it again unless its run out of free addresses and
    assigned it to another host.

    You're describing "automatic allocation" as defined in the RFC:

    DHCP supports three mechanisms for IP address allocation. In
    "automatic allocation", DHCP assigns a permanent IP address to a
    client.

    In the server settings, set your leases to something long (or
    infinite, if you're *really* sure this is what you want) and make your
    pool of addresses big.


  7. Re: Dynamically assign IP based on MAC

    David Nicoson wrote:
    > On Jan 31, 2:28 pm, Joe Beanfish wrote:
    >> Even after having been turned off?

    >
    > A well-behaved server (e.g, ISC) will remember the IP it last gave the
    > client and offer it again unless its run out of free addresses and
    > assigned it to another host.
    >
    > You're describing "automatic allocation" as defined in the RFC:
    >
    > DHCP supports three mechanisms for IP address allocation. In
    > "automatic allocation", DHCP assigns a permanent IP address to a
    > client.
    >
    > In the server settings, set your leases to something long (or
    > infinite, if you're *really* sure this is what you want) and make your
    > pool of addresses big.
    >


    You can also set IP address allocation based on MAC address. In dhcpd.conf, you include a section like

    #
    # establish fixed addresses for the computers that previously
    # had hard-coded IP addresses. If an ethernet card is changed, the
    # machine will receive an address from the dynamic range until the
    # new ethernet address has been entered below. The lease time for these
    # machines is much longer.
    #
    group {
    option subnet-mask 255.255.255.0;
    option broadcast-address 10.10.10.255;
    max-lease-time 100000;
    #
    host printer_1 {
    hardware ethernet 00:01:E6:01:528;
    fixed-address 10.10.10.3;
    }
    .......
    }

    There should be a host block for every address you want to be fixed.

    Larry


+ Reply to Thread