Networking Forums  

Go Back   Networking Forums > Networking Newsgroups > Linux Networking

DHCP

Reply
 
Thread Tools Display Modes
  #1  
Old 02-01-2005, 10:07 PM
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 000:09:28:05:56 ; ddns-hostname
wwebster-1;}
host cclark-1 { hardware ethernet 00:A02: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).



Noah Roberts
Reply With Quote
  #2  
Old 02-01-2005, 10:50 PM
Kevin Brown
Guest
 
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  
Old 02-03-2005, 08:23 PM
Andrei Ivanov
Guest
 
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  
Old 02-03-2005, 09:57 PM
Tim Rhodes
Guest
 
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 .............. (E-Mail Removed) ..
Reply With Quote
  #5  
Old 02-04-2005, 12:29 AM
prg
Guest
 
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  
Old 02-04-2005, 12:36 AM
Bit Twister
Guest
 
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  
Old 02-04-2005, 01:08 AM
prg
Guest
 
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  
Old 02-04-2005, 01:53 AM
Bit Twister
Guest
 
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  
Old 02-04-2005, 02:14 AM
prg
Guest
 
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

Tags
dhcp

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
Forum Jump


All times are GMT. The time now is 07:51 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.