Networking Forums

Networking Forums > Computer Networking > Linux Networking > Dynamically assign IP based on MAC

Reply
Thread Tools Display Modes

Dynamically assign IP based on MAC

 
 
DEBEDb
Guest
Posts: n/a

 
      01-30-2007, 05:06 PM
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.

 
Reply With Quote
 
 
 
 
Joe Beanfish
Guest
Posts: n/a

 
      01-30-2007, 06:09 PM
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.
 
Reply With Quote
 
Tauno Voipio
Guest
Posts: n/a

 
      01-30-2007, 06:20 PM
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
 
Reply With Quote
 
Joe Beanfish
Guest
Posts: n/a

 
      01-31-2007, 06:28 PM
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?
 
Reply With Quote
 
Pascal Hambourg
Guest
Posts: n/a

 
      01-31-2007, 08:05 PM
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.
 
Reply With Quote
 
David Nicoson
Guest
Posts: n/a

 
      01-31-2007, 09:08 PM
On Jan 31, 2:28 pm, Joe Beanfish <j...@nospam.duh> 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.

 
Reply With Quote
 
Larry Finger
Guest
Posts: n/a

 
      02-01-2007, 12:42 AM
David Nicoson wrote:
> On Jan 31, 2:28 pm, Joe Beanfish <j...@nospam.duh> 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 With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically Change SSID fernandez.dan@gmail.com Wireless Internet 1 06-20-2008 01:04 AM
How to Assign IP Addresses to networked devices based upon MAC Mr. Smith Windows Networking 5 08-10-2007 07:43 PM
How do I change IP address dynamically? linuxlover992000@yahoo.com Linux Networking 17 06-21-2006 08:08 PM
Dynamically detect network environment wim delvaux Linux Networking 1 11-27-2003 12:18 AM
Assign an IP address or let Windows assign one? Jackie Windows Networking 4 10-11-2003 10:53 AM



1 2 3 4 5 6 7 8 9 10 11