Bluehost.com Web Hosting $6.95

DHCP

This is a discussion on DHCP within the Linux Networking forums, part of the Linux Forums category; > 2. Secondly, I am also wondering if a "pool" of MAC addresses can be > setup so ...


Go Back   Usenet Forums > Linux Forums > Linux Networking

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-01-2005
Noah Roberts
 
Posts: n/a
Default Re: DHCP


> 2. Secondly, I am also wondering if a "pool" of MAC addresses can be


> setup so that only MAC's listed can be given an IP, but is random

within
> a range of valid IP addresses.


This one can at least.

subnet 10.4.0.0 netmask 255.255.0.0 {
authoritive;
option subnet-mask 255.255.0.0;
option broadcast-address 10.0.255.255;
pool {
range 10.4.254.1 10.4.254.254;
option routers 10.4.0.1;
option domain-name-servers 10.4.0.7;
default-lease-time 120;
max-lease-time 120;
allow unknown clients;
}
pool {
range 10.4.1.1 10.4.5.254;
option routers 10.4.0.1;
option domain-name-servers 10.0.0.17, 10.0.0.23;
default-lease-time 1209600;
max-lease-time 1209600;
deny unknown clients;
}
}

host wwebster-1 { hardware ethernet 00:D0:09:28:05:56 ; ddns-hostname
wwebster-1;}
host cclark-1 { hardware ethernet 00:A0:D2:1A:7C:A5 ; ddns-hostname
cclark-1;}

These computers will be given IP's out of the second pool of addresses.
The first pool is not needed for you most likely (it is part of a
captive portal system).

Reply With Quote
  #2 (permalink)  
Old 02-01-2005
Kevin Brown
 
Posts: n/a
Default DHCP

Hello all,

I have two questions regard DHCP:

1. Can I have DHCP execute a script for each lease it gives? What I
would like to do is for everytime an IP is assigned, I would like it to
execute a script which will set bandwidth restrictions on that IP (two
arguments of that script would have to be MAC address and IP address).
Also, is there a way of running a script upon termination of a lease (do
the opposite of the first script).

2. Secondly, I am also wondering if a "pool" of MAC addresses can be
setup so that only MAC's listed can be given an IP, but is random within
a range of valid IP addresses.

Thanks in advance.
Kevin Brown
Reply With Quote
  #3 (permalink)  
Old 02-03-2005
Andrei Ivanov
 
Posts: n/a
Default Re: DHCP

Kevin Brown <-NOSPAM-itismekevinb-NOSPAM-@hotmail.com> wrote:
> 1. Can I have DHCP execute a script for each lease it gives? What I
> would like to do is for everytime an IP is assigned, I would like it to
> execute a script which will set bandwidth restrictions on that IP (two
> arguments of that script would have to be MAC address and IP address).
> Also, is there a way of running a script upon termination of a lease (do
> the opposite of the first script).


You script may monitor /var/log/messages for records written on behalf
of DHCP daemon every time client requests/reconfirms/releases IP address,
and then do whatever you need (reconfigure iptables, or router).

--
andrei
Reply With Quote
  #4 (permalink)  
Old 02-03-2005
Tim Rhodes
 
Posts: n/a
Default Re: DHCP

Kevin Brown <-NOSPAM-itismekevinb-NOSPAM-@hotmail.com> wrote:
> 1. Can I have DHCP execute a script for each lease it gives? What I
> would like to do is for everytime an IP is assigned, I would like it to
> execute a script which will set bandwidth restrictions on that IP (two
> arguments of that script would have to be MAC address and IP address).
> Also, is there a way of running a script upon termination of a lease (do
> the opposite of the first script).

On a quick review, I can't find the man page/reference where I found this
before, but for every new DHCP lease (my system uses dhclient), the script
/etc/dhclient-exit-hooks is executed. I can't recall if I set this up in
a config file or it's executed if it exists. I use this script to update
/etc/hosts when I get a new IP address. When called, environment variables
contain various details about the event.
--
... Tim Rhodes ........................ http://rhodes.cc.vt.edu/~rhodes ..
... NIS-Systems Support, Virginia Tech .............. Tim.Rhodes@vt.edu ..
Reply With Quote
  #5 (permalink)  
Old 02-04-2005
prg
 
Posts: n/a
Default Re: DHCP


Tim Rhodes wrote:
> Kevin Brown <-NOSPAM-itismekevinb-NOSPAM-@hotmail.com> wrote:
> > 1. Can I have DHCP execute a script for each lease it gives? What

I
> > would like to do is for everytime an IP is assigned, I would like

it to
> > execute a script which will set bandwidth restrictions on that IP

(two
> > arguments of that script would have to be MAC address and IP

address).
> > Also, is there a way of running a script upon termination of a

lease (do
> > the opposite of the first script).

> On a quick review, I can't find the man page/reference where I found

this
> before, but for every new DHCP lease (my system uses dhclient), the

script
> /etc/dhclient-exit-hooks is executed. I can't recall if I set this

up in
> a config file or it's executed if it exists. I use this script to

update
> /etc/hosts when I get a new IP address. When called, environment

variables
> contain various details about the event.


/sbin/dhclient-script ?

Reply With Quote
  #6 (permalink)  
Old 02-04-2005
Bit Twister
 
Posts: n/a
Default Re: DHCP

On 3 Feb 2005 16:29:05 -0800, prg wrote:
>
> /sbin/dhclient-script ?


That is the script which calls /etc/dhclient-exit-hooks if it exists.
/sbin/dhclient-script should not be modifed.
User code goes in /etc/dhclient-exit-hooks.

Reply With Quote
  #7 (permalink)  
Old 02-04-2005
prg
 
Posts: n/a
Default Re: DHCP


Bit Twister wrote:
> On 3 Feb 2005 16:29:05 -0800, prg wrote:
> >
> > /sbin/dhclient-script ?

>
> That is the script which calls /etc/dhclient-exit-hooks if it exists.
> /sbin/dhclient-script should not be modifed.
> User code goes in /etc/dhclient-exit-hooks.


"...the script which calls /etc/dhclient-exit-hooks" is what he could
not find, so I told him how to find where /etc/dhclient-exit-hooks
(exit_with_hooks) is called. No? That's the whole point of
exit_with_hooks. No?

But I may have misunderstood -- not the first time ;)

regards,
prg
email above disabled

Reply With Quote
  #8 (permalink)  
Old 02-04-2005
Bit Twister
 
Posts: n/a
Default Re: DHCP

On 3 Feb 2005 17:08:37 -0800, prg wrote:
>
> But I may have misunderstood -- not the first time ;)


Tim had indicated he could not remember how he knew about dhclient-exit-hooks

man dhclient-script talks about it.

I misunderstood your response. I assumed you were suggesting the user
modify /sbin/dhclient-script. O:-)

Reply With Quote
  #9 (permalink)  
Old 02-04-2005
prg
 
Posts: n/a
Default Re: DHCP


Bit Twister wrote:
> On 3 Feb 2005 17:08:37 -0800, prg wrote:
> >
> > But I may have misunderstood -- not the first time ;)

>
> Tim had indicated he could not remember how he knew about

dhclient-exit-hooks
>
> man dhclient-script talks about it.
>
> I misunderstood your response. I assumed you were suggesting the user
> modify /sbin/dhclient-script. O:-)


And so might someone else without you prodding me into a clarification.

All bases covered. Is that teamwork, or what?

prg

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 01:38 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0