mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-30 13:57:50 +00:00
Moved to server/
This commit is contained in:
parent
94db3c801c
commit
034aa896ce
334
bootp.c
334
bootp.c
@ -1,334 +0,0 @@
|
||||
/* bootp.c
|
||||
|
||||
BOOTP Protocol support. */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996 The Internet Software Consortium.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of The Internet Software Consortium nor the names
|
||||
* of its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
|
||||
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This software has been written for the Internet Software Consortium
|
||||
* by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
||||
* Enterprises. To learn more about the Internet Software Consortium,
|
||||
* see ``http://www.vix.com/isc''. To learn more about Vixie
|
||||
* Enterprises, see ``http://www.vix.com''.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"$Id: bootp.c,v 1.24 1997/02/22 08:36:36 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
||||
void bootp (packet)
|
||||
struct packet *packet;
|
||||
{
|
||||
int result;
|
||||
struct host_decl *hp;
|
||||
struct host_decl *host = (struct host_decl *)0;
|
||||
struct packet outgoing;
|
||||
struct dhcp_packet raw;
|
||||
struct sockaddr_in to;
|
||||
struct in_addr from;
|
||||
struct hardware hto;
|
||||
struct tree_cache *options [256];
|
||||
struct subnet *subnet;
|
||||
struct lease *lease;
|
||||
struct iaddr ip_address;
|
||||
int i;
|
||||
|
||||
note ("BOOTREQUEST from %s via %s",
|
||||
print_hw_addr (packet -> raw -> htype,
|
||||
packet -> raw -> hlen,
|
||||
packet -> raw -> chaddr),
|
||||
packet -> raw -> giaddr.s_addr
|
||||
? inet_ntoa (packet -> raw -> giaddr)
|
||||
: packet -> interface -> name);
|
||||
|
||||
|
||||
|
||||
if (!locate_network (packet))
|
||||
return;
|
||||
|
||||
hp = find_hosts_by_haddr (packet -> raw -> htype,
|
||||
packet -> raw -> chaddr,
|
||||
packet -> raw -> hlen);
|
||||
|
||||
lease = find_lease (packet, packet -> shared_network);
|
||||
|
||||
/* Find an IP address in the host_decl that matches the
|
||||
specified network. */
|
||||
if (hp)
|
||||
subnet = find_host_for_network (&hp, &ip_address,
|
||||
packet -> shared_network);
|
||||
else
|
||||
subnet = (struct subnet *)0;
|
||||
|
||||
if (!subnet) {
|
||||
/* We didn't find an applicable host declaration.
|
||||
Just in case we may be able to dynamically assign
|
||||
an address, see if there's a host declaration
|
||||
that doesn't have an ip address associated with it. */
|
||||
if (hp) {
|
||||
for (; hp; hp = hp -> n_ipaddr) {
|
||||
if (!hp -> fixed_addr) {
|
||||
host = hp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (host && (!host -> group -> allow_booting)) {
|
||||
note ("Ignoring excluded BOOTP client %s",
|
||||
host -> name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (host && (!host -> group -> allow_bootp)) {
|
||||
note ("Ignoring BOOTP request from client %s",
|
||||
host -> name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we've been told not to boot unknown clients,
|
||||
and we didn't find any host record for this client,
|
||||
ignore it. */
|
||||
if (!host && !(packet -> shared_network ->
|
||||
group -> boot_unknown_clients)) {
|
||||
note ("Ignoring unknown BOOTP client %s via %s",
|
||||
print_hw_addr (packet -> raw -> htype,
|
||||
packet -> raw -> hlen,
|
||||
packet -> raw -> chaddr),
|
||||
packet -> raw -> giaddr.s_addr
|
||||
? inet_ntoa (packet -> raw -> giaddr)
|
||||
: packet -> interface -> name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If we've been told not to boot with bootp on this
|
||||
network, ignore it. */
|
||||
if (!host &&
|
||||
!(packet -> shared_network -> group -> allow_bootp)) {
|
||||
note ("Ignoring BOOTP request from client %s via %s",
|
||||
print_hw_addr (packet -> raw -> htype,
|
||||
packet -> raw -> hlen,
|
||||
packet -> raw -> chaddr),
|
||||
packet -> raw -> giaddr.s_addr
|
||||
? inet_ntoa (packet -> raw -> giaddr)
|
||||
: packet -> interface -> name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If the packet is from a host we don't know and there
|
||||
are no dynamic bootp addresses on the network it came
|
||||
in on, drop it on the floor. */
|
||||
if (!(packet -> shared_network -> group -> dynamic_bootp)) {
|
||||
lose:
|
||||
note ("No applicable record for BOOTP host %s via %s",
|
||||
print_hw_addr (packet -> raw -> htype,
|
||||
packet -> raw -> hlen,
|
||||
packet -> raw -> chaddr),
|
||||
packet -> raw -> giaddr.s_addr
|
||||
? inet_ntoa (packet -> raw -> giaddr)
|
||||
: packet -> interface -> name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If a lease has already been assigned to this client
|
||||
and it's still okay to use dynamic bootp on
|
||||
that lease, reassign it. */
|
||||
if (lease) {
|
||||
/* If this lease can be used for dynamic bootp,
|
||||
do so. */
|
||||
if ((lease -> flags & DYNAMIC_BOOTP_OK)) {
|
||||
|
||||
/* If it's not a DYNAMIC_BOOTP lease,
|
||||
release it before reassigning it
|
||||
so that we don't get a lease
|
||||
conflict. */
|
||||
if (!(lease -> flags & BOOTP_LEASE))
|
||||
release_lease (lease);
|
||||
|
||||
lease -> host = host;
|
||||
ack_lease (packet, lease, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If dynamic BOOTP is no longer allowed for
|
||||
this lease, set it free. */
|
||||
release_lease (lease);
|
||||
}
|
||||
|
||||
/* If there are dynamic bootp addresses that might be
|
||||
available, try to snag one. */
|
||||
for (lease = packet -> shared_network -> last_lease;
|
||||
lease && lease -> ends <= cur_time;
|
||||
lease = lease -> prev) {
|
||||
if ((lease -> flags & DYNAMIC_BOOTP_OK)) {
|
||||
lease -> host = host;
|
||||
ack_lease (packet, lease, 0, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
goto lose;
|
||||
}
|
||||
|
||||
/* Make sure we're allowed to boot this client. */
|
||||
if (hp && (!hp -> group -> allow_booting)) {
|
||||
note ("Ignoring excluded BOOTP client %s",
|
||||
hp -> name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make sure we're allowed to boot this client with bootp. */
|
||||
if (hp && (!hp -> group -> allow_bootp)) {
|
||||
note ("Ignoring BOOTP request from client %s",
|
||||
hp -> name);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set up the outgoing packet... */
|
||||
memset (&outgoing, 0, sizeof outgoing);
|
||||
memset (&raw, 0, sizeof raw);
|
||||
outgoing.raw = &raw;
|
||||
|
||||
/* Come up with a list of options that we want to send to this
|
||||
client. Start with the per-subnet options, and then override
|
||||
those with client-specific options. */
|
||||
|
||||
memcpy (options, subnet -> group -> options, sizeof options);
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (hp -> group -> options [i])
|
||||
options [i] = hp -> group -> options [i];
|
||||
}
|
||||
|
||||
/* Pack the options into the buffer. Unlike DHCP, we can't
|
||||
pack options into the filename and server name buffers. */
|
||||
|
||||
outgoing.packet_length =
|
||||
cons_options (packet, outgoing.raw, options, 0, 0);
|
||||
if (outgoing.packet_length < BOOTP_MIN_LEN)
|
||||
outgoing.packet_length = BOOTP_MIN_LEN;
|
||||
|
||||
/* Take the fields that we care about... */
|
||||
raw.op = BOOTREPLY;
|
||||
raw.htype = packet -> raw -> htype;
|
||||
raw.hlen = packet -> raw -> hlen;
|
||||
memcpy (raw.chaddr, packet -> raw -> chaddr, raw.hlen);
|
||||
memset (&raw.chaddr [raw.hlen], 0,
|
||||
(sizeof raw.chaddr) - raw.hlen);
|
||||
raw.hops = packet -> raw -> hops;
|
||||
raw.xid = packet -> raw -> xid;
|
||||
raw.secs = packet -> raw -> secs;
|
||||
raw.flags = 0;
|
||||
raw.ciaddr = packet -> raw -> ciaddr;
|
||||
memcpy (&raw.yiaddr, ip_address.iabuf, sizeof raw.yiaddr);
|
||||
|
||||
/* Figure out the address of the next server. */
|
||||
if (hp && hp -> group -> next_server.len)
|
||||
memcpy (&raw.siaddr, hp -> group -> next_server.iabuf, 4);
|
||||
else if (subnet -> group -> next_server.len)
|
||||
memcpy (&raw.siaddr, subnet -> group -> next_server.iabuf, 4);
|
||||
else if (subnet -> interface_address.len)
|
||||
memcpy (&raw.siaddr, subnet -> interface_address.iabuf, 4);
|
||||
else
|
||||
raw.siaddr = packet -> interface -> primary_address;
|
||||
|
||||
raw.giaddr = packet -> raw -> giaddr;
|
||||
if (hp -> group -> server_name) {
|
||||
strncpy (raw.sname, hp -> group -> server_name,
|
||||
(sizeof raw.sname) - 1);
|
||||
raw.sname [(sizeof raw.sname) - 1] = 0;
|
||||
}
|
||||
if (hp -> group -> filename) {
|
||||
strncpy (raw.file, hp -> group -> filename,
|
||||
(sizeof raw.file) - 1);
|
||||
raw.file [(sizeof raw.file) - 1] = 0;
|
||||
}
|
||||
|
||||
/* Set up the hardware destination address... */
|
||||
hto.htype = packet -> raw -> htype;
|
||||
hto.hlen = packet -> raw -> hlen;
|
||||
memcpy (hto.haddr, packet -> raw -> chaddr, hto.hlen);
|
||||
|
||||
from = packet -> interface -> primary_address;
|
||||
|
||||
/* Report what we're doing... */
|
||||
note ("BOOTREPLY for %s to %s (%s) via %s",
|
||||
piaddr (ip_address), hp -> name,
|
||||
print_hw_addr (packet -> raw -> htype,
|
||||
packet -> raw -> hlen,
|
||||
packet -> raw -> chaddr),
|
||||
packet -> raw -> giaddr.s_addr
|
||||
? inet_ntoa (packet -> raw -> giaddr)
|
||||
: packet -> interface -> name);
|
||||
|
||||
/* Set up the parts of the address that are in common. */
|
||||
to.sin_family = AF_INET;
|
||||
#ifdef HAVE_SA_LEN
|
||||
to.sin_len = sizeof to;
|
||||
#endif
|
||||
memset (to.sin_zero, 0, sizeof to.sin_zero);
|
||||
|
||||
/* If this was gatewayed, send it back to the gateway... */
|
||||
if (raw.giaddr.s_addr) {
|
||||
to.sin_addr = raw.giaddr;
|
||||
to.sin_port = local_port;
|
||||
|
||||
#ifdef USE_FALLBACK
|
||||
result = send_fallback (&fallback_interface,
|
||||
(struct packet *)0,
|
||||
&raw, outgoing.packet_length,
|
||||
from, &to, &hto);
|
||||
if (result < 0)
|
||||
warn ("send_fallback: %m");
|
||||
return;
|
||||
#endif
|
||||
/* Otherwise, broadcast it on the local network. */
|
||||
} else {
|
||||
to.sin_addr.s_addr = INADDR_BROADCAST;
|
||||
to.sin_port = remote_port; /* XXX */
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
result = send_packet (packet -> interface,
|
||||
packet, &raw, outgoing.packet_length,
|
||||
from, &to, &hto);
|
||||
if (result < 0)
|
||||
warn ("send_packet: %m");
|
||||
}
|
||||
|
||||
void relay (ip, packet, length)
|
||||
struct interface_info *ip;
|
||||
struct dhcp_packet *packet;
|
||||
int length;
|
||||
{
|
||||
}
|
521
conflex.c
521
conflex.c
@ -1,521 +0,0 @@
|
||||
/* conflex.c
|
||||
|
||||
Lexical scanner for dhcpd config file... */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of The Internet Software Consortium nor the names
|
||||
* of its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
|
||||
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This software has been written for the Internet Software Consortium
|
||||
* by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
||||
* Enterprises. To learn more about the Internet Software Consortium,
|
||||
* see ``http://www.vix.com/isc''. To learn more about Vixie
|
||||
* Enterprises, see ``http://www.vix.com''.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"$Id: conflex.c,v 1.22 1997/02/22 12:23:40 mellon Exp $ Copyright (c) 1995, 1996, 1997 The Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
#include "dhctoken.h"
|
||||
#include <ctype.h>
|
||||
|
||||
int lexline;
|
||||
int lexchar;
|
||||
char *token_line;
|
||||
char *prev_line;
|
||||
char *cur_line;
|
||||
char *tlname;
|
||||
|
||||
static char line1 [81];
|
||||
static char line2 [81];
|
||||
static int lpos;
|
||||
static int line;
|
||||
static int tlpos;
|
||||
static int tline;
|
||||
static int token;
|
||||
static int ugflag;
|
||||
static char *tval;
|
||||
static char tokbuf [1500];
|
||||
|
||||
#ifdef OLD_LEXER
|
||||
char comments [4096];
|
||||
int comment_index;
|
||||
#endif
|
||||
|
||||
|
||||
static int get_char PROTO ((FILE *));
|
||||
static int get_token PROTO ((FILE *));
|
||||
static void skip_to_eol PROTO ((FILE *));
|
||||
static int read_string PROTO ((FILE *));
|
||||
static int read_number PROTO ((int, FILE *));
|
||||
static int read_num_or_name PROTO ((int, FILE *));
|
||||
static int intern PROTO ((char *, int));
|
||||
|
||||
void new_parse (name)
|
||||
char *name;
|
||||
{
|
||||
tlname = name;
|
||||
lpos = line = 1;
|
||||
cur_line = line1;
|
||||
prev_line = line2;
|
||||
token_line = cur_line;
|
||||
cur_line [0] = prev_line [0] = 0;
|
||||
warnings_occurred = 0;
|
||||
}
|
||||
|
||||
static int get_char (cfile)
|
||||
FILE *cfile;
|
||||
{
|
||||
int c = getc (cfile);
|
||||
if (!ugflag) {
|
||||
if (c == EOL) {
|
||||
if (cur_line == line1) {
|
||||
cur_line = line2;
|
||||
prev_line = line1;
|
||||
} else {
|
||||
cur_line = line2;
|
||||
prev_line = line1;
|
||||
}
|
||||
line++;
|
||||
lpos = 1;
|
||||
cur_line [0] = 0;
|
||||
} else if (c != EOF) {
|
||||
if (lpos <= 81) {
|
||||
cur_line [lpos - 1] = c;
|
||||
cur_line [lpos] = 0;
|
||||
}
|
||||
lpos++;
|
||||
}
|
||||
} else
|
||||
ugflag = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
static int get_token (cfile)
|
||||
FILE *cfile;
|
||||
{
|
||||
int c;
|
||||
int ttok;
|
||||
static char tb [2];
|
||||
int l, p, u;
|
||||
|
||||
do {
|
||||
l = line;
|
||||
p = lpos;
|
||||
u = ugflag;
|
||||
|
||||
c = get_char (cfile);
|
||||
#ifdef OLD_LEXER
|
||||
if (c == '\n' && p == 1 && !u
|
||||
&& comment_index < sizeof comments)
|
||||
comments [comment_index++] = '\n';
|
||||
#endif
|
||||
|
||||
if (isascii (c) && isspace (c))
|
||||
continue;
|
||||
if (c == '#') {
|
||||
#ifdef OLD_LEXER
|
||||
if (comment_index < sizeof comments)
|
||||
comments [comment_index++] = '#';
|
||||
#endif
|
||||
skip_to_eol (cfile);
|
||||
continue;
|
||||
}
|
||||
if (c == '"') {
|
||||
lexline = l;
|
||||
lexchar = p;
|
||||
ttok = read_string (cfile);
|
||||
break;
|
||||
}
|
||||
if ((isascii (c) && isdigit (c)) || c == '-') {
|
||||
lexline = l;
|
||||
lexchar = p;
|
||||
ttok = read_number (c, cfile);
|
||||
break;
|
||||
} else if (isascii (c) && isalpha (c)) {
|
||||
lexline = l;
|
||||
lexchar = p;
|
||||
ttok = read_num_or_name (c, cfile);
|
||||
break;
|
||||
} else {
|
||||
lexline = l;
|
||||
lexchar = p;
|
||||
tb [0] = c;
|
||||
tb [1] = 0;
|
||||
tval = tb;
|
||||
ttok = c;
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
return ttok;
|
||||
}
|
||||
|
||||
int next_token (rval, cfile)
|
||||
char **rval;
|
||||
FILE *cfile;
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (token) {
|
||||
if (lexline != tline)
|
||||
token_line = cur_line;
|
||||
lexchar = tlpos;
|
||||
lexline = tline;
|
||||
rv = token;
|
||||
token = 0;
|
||||
} else {
|
||||
rv = get_token (cfile);
|
||||
token_line = cur_line;
|
||||
}
|
||||
if (rval)
|
||||
*rval = tval;
|
||||
#ifdef DEBUG_TOKENS
|
||||
fprintf (stderr, "%s:%d ", tval, rv);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
int peek_token (rval, cfile)
|
||||
char **rval;
|
||||
FILE *cfile;
|
||||
{
|
||||
int x;
|
||||
|
||||
if (!token) {
|
||||
tlpos = lexchar;
|
||||
tline = lexline;
|
||||
token = get_token (cfile);
|
||||
if (lexline != tline)
|
||||
token_line = prev_line;
|
||||
x = lexchar; lexchar = tlpos; tlpos = x;
|
||||
x = lexline; lexline = tline; tline = x;
|
||||
}
|
||||
if (rval)
|
||||
*rval = tval;
|
||||
#ifdef DEBUG_TOKENS
|
||||
fprintf (stderr, "(%s:%d) ", tval, token);
|
||||
#endif
|
||||
return token;
|
||||
}
|
||||
|
||||
static void skip_to_eol (cfile)
|
||||
FILE *cfile;
|
||||
{
|
||||
int c;
|
||||
do {
|
||||
c = get_char (cfile);
|
||||
if (c == EOF)
|
||||
return;
|
||||
#ifdef OLD_LEXER
|
||||
if (comment_index < sizeof (comments))
|
||||
comments [comment_index++] = c;
|
||||
#endif
|
||||
if (c == EOL) {
|
||||
return;
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
|
||||
static int read_string (cfile)
|
||||
FILE *cfile;
|
||||
{
|
||||
int i;
|
||||
int bs = 0;
|
||||
int c;
|
||||
|
||||
for (i = 0; i < sizeof tokbuf; i++) {
|
||||
c = get_char (cfile);
|
||||
if (c == EOF) {
|
||||
parse_warn ("eof in string constant");
|
||||
break;
|
||||
}
|
||||
if (bs) {
|
||||
bs = 0;
|
||||
tokbuf [i] = c;
|
||||
} else if (c == '\\')
|
||||
bs = 1;
|
||||
else if (c == '"')
|
||||
break;
|
||||
else
|
||||
tokbuf [i] = c;
|
||||
}
|
||||
/* Normally, I'd feel guilty about this, but we're talking about
|
||||
strings that'll fit in a DHCP packet here... */
|
||||
if (i == sizeof tokbuf) {
|
||||
parse_warn ("string constant larger than internal buffer");
|
||||
--i;
|
||||
}
|
||||
tokbuf [i] = 0;
|
||||
tval = tokbuf;
|
||||
return STRING;
|
||||
}
|
||||
|
||||
static int read_number (c, cfile)
|
||||
int c;
|
||||
FILE *cfile;
|
||||
{
|
||||
int seenx = 0;
|
||||
int i = 0;
|
||||
int token = NUMBER;
|
||||
|
||||
tokbuf [i++] = c;
|
||||
for (; i < sizeof tokbuf; i++) {
|
||||
c = get_char (cfile);
|
||||
if (!seenx && c == 'x') {
|
||||
seenx = 1;
|
||||
#ifndef OLD_LEXER
|
||||
} else if (isascii (c) && !isxdigit (c) &&
|
||||
(c == '-' || c == '_' || isalpha (c))) {
|
||||
token = NAME;
|
||||
} else if (isascii (c) && !isdigit (c) && isxdigit (c)) {
|
||||
token = NUMBER_OR_NAME;
|
||||
#endif
|
||||
} else if (!isascii (c) || !isxdigit (c)) {
|
||||
ungetc (c, cfile);
|
||||
ugflag = 1;
|
||||
break;
|
||||
}
|
||||
tokbuf [i] = c;
|
||||
}
|
||||
if (i == sizeof tokbuf) {
|
||||
parse_warn ("numeric token larger than internal buffer");
|
||||
--i;
|
||||
}
|
||||
tokbuf [i] = 0;
|
||||
tval = tokbuf;
|
||||
return token;
|
||||
}
|
||||
|
||||
static int read_num_or_name (c, cfile)
|
||||
int c;
|
||||
FILE *cfile;
|
||||
{
|
||||
int i = 0;
|
||||
int rv = NUMBER_OR_NAME;
|
||||
tokbuf [i++] = c;
|
||||
for (; i < sizeof tokbuf; i++) {
|
||||
c = get_char (cfile);
|
||||
if (!isascii (c) ||
|
||||
(c != '-' && c != '_' && !isalnum (c))) {
|
||||
ungetc (c, cfile);
|
||||
ugflag = 1;
|
||||
break;
|
||||
}
|
||||
if (!isxdigit (c))
|
||||
rv = NAME;
|
||||
tokbuf [i] = c;
|
||||
}
|
||||
if (i == sizeof tokbuf) {
|
||||
parse_warn ("token larger than internal buffer");
|
||||
--i;
|
||||
}
|
||||
tokbuf [i] = 0;
|
||||
tval = tokbuf;
|
||||
return intern (tval, rv);
|
||||
}
|
||||
|
||||
static int intern (atom, dfv)
|
||||
char *atom;
|
||||
int dfv;
|
||||
{
|
||||
if (!isascii (atom [0]))
|
||||
return dfv;
|
||||
|
||||
switch (tolower (atom [0])) {
|
||||
case 'a':
|
||||
if (!strcasecmp (atom + 1, "llow"))
|
||||
return ALLOW;
|
||||
if (!strcasecmp (atom + 1, "lias"))
|
||||
return ALIAS;
|
||||
break;
|
||||
case 'b':
|
||||
if (!strcasecmp (atom + 1, "ootp"))
|
||||
return BOOTP;
|
||||
if (!strcasecmp (atom + 1, "ooting"))
|
||||
return BOOTING;
|
||||
if (!strcasecmp (atom + 1, "oot-unknown-clients"))
|
||||
return BOOT_UNKNOWN_CLIENTS;
|
||||
case 'c':
|
||||
if (!strcasecmp (atom + 1, "lass"))
|
||||
return CLASS;
|
||||
if (!strcasecmp (atom + 1, "iaddr"))
|
||||
return CIADDR;
|
||||
if (!strcasecmp (atom + 1, "lient-identifier"))
|
||||
return CLIENT_IDENTIFIER;
|
||||
break;
|
||||
case 'd':
|
||||
if (!strcasecmp (atom + 1, "eny"))
|
||||
return DENY;
|
||||
if (!strncasecmp (atom + 1, "efault", 6)) {
|
||||
if (!atom [7])
|
||||
return DEFAULT;
|
||||
if (!strcasecmp (atom + 7, "-lease-time"))
|
||||
return DEFAULT_LEASE_TIME;
|
||||
break;
|
||||
}
|
||||
if (!strncasecmp (atom + 1, "ynamic-bootp", 12)) {
|
||||
if (!atom [13])
|
||||
return DYNAMIC_BOOTP;
|
||||
if (!strcasecmp (atom + 13, "-lease-cutoff"))
|
||||
return DYNAMIC_BOOTP_LEASE_CUTOFF;
|
||||
if (!strcasecmp (atom + 13, "-lease-length"))
|
||||
return DYNAMIC_BOOTP_LEASE_LENGTH;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'e':
|
||||
if (!strcasecmp (atom + 1, "thernet"))
|
||||
return ETHERNET;
|
||||
if (!strcasecmp (atom + 1, "nds"))
|
||||
return ENDS;
|
||||
if (!strcasecmp (atom + 1, "xpire"))
|
||||
return EXPIRE;
|
||||
break;
|
||||
case 'f':
|
||||
if (!strcasecmp (atom + 1, "ilename"))
|
||||
return FILENAME;
|
||||
if (!strcasecmp (atom + 1, "ixed-address"))
|
||||
return FIXED_ADDR;
|
||||
break;
|
||||
case 'g':
|
||||
if (!strcasecmp (atom + 1, "iaddr"))
|
||||
return GIADDR;
|
||||
if (!strcasecmp (atom + 1, "roup"))
|
||||
return GROUP;
|
||||
if (!strcasecmp (atom + 1, "et-lease-hostnames"))
|
||||
return GET_LEASE_HOSTNAMES;
|
||||
break;
|
||||
case 'h':
|
||||
if (!strcasecmp (atom + 1, "ost"))
|
||||
return HOST;
|
||||
if (!strcasecmp (atom + 1, "ardware"))
|
||||
return HARDWARE;
|
||||
break;
|
||||
case 'i':
|
||||
if (!strcasecmp (atom + 1, "nterface"))
|
||||
return INTERFACE;
|
||||
break;
|
||||
case 'l':
|
||||
if (!strcasecmp (atom + 1, "ease"))
|
||||
return LEASE;
|
||||
break;
|
||||
case 'm':
|
||||
if (!strcasecmp (atom + 1, "ax-lease-time"))
|
||||
return MAX_LEASE_TIME;
|
||||
if (!strncasecmp (atom + 1, "edi", 3)) {
|
||||
if (!strcasecmp (atom + 4, "a"))
|
||||
return MEDIA;
|
||||
if (!strcasecmp (atom + 4, "um"))
|
||||
return MEDIUM;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'n':
|
||||
if (!strcasecmp (atom + 1, "etmask"))
|
||||
return NETMASK;
|
||||
if (!strcasecmp (atom + 1, "ext-server"))
|
||||
return NEXT_SERVER;
|
||||
break;
|
||||
case 'o':
|
||||
if (!strcasecmp (atom + 1, "ption"))
|
||||
return OPTION;
|
||||
if (!strcasecmp (atom + 1, "ne-lease-per-client"))
|
||||
return ONE_LEASE_PER_CLIENT;
|
||||
break;
|
||||
case 'p':
|
||||
if (!strcasecmp (atom + 1, "acket"))
|
||||
return PACKET;
|
||||
break;
|
||||
case 'r':
|
||||
if (!strcasecmp (atom + 1, "ange"))
|
||||
return RANGE;
|
||||
if (!strcasecmp (atom + 1, "equest"))
|
||||
return REQUEST;
|
||||
if (!strcasecmp (atom + 1, "equire"))
|
||||
return REQUIRE;
|
||||
if (!strcasecmp (atom + 1, "etry"))
|
||||
return RETRY;
|
||||
if (!strcasecmp (atom + 1, "enew"))
|
||||
return RENEW;
|
||||
if (!strcasecmp (atom + 1, "ebind"))
|
||||
return REBIND;
|
||||
break;
|
||||
case 's':
|
||||
if (!strcasecmp (atom + 1, "tarts"))
|
||||
return STARTS;
|
||||
if (!strcasecmp (atom + 1, "iaddr"))
|
||||
return SIADDR;
|
||||
if (!strcasecmp (atom + 1, "ubnet"))
|
||||
return SUBNET;
|
||||
if (!strcasecmp (atom + 1, "hared-network"))
|
||||
return SHARED_NETWORK;
|
||||
if (!strcasecmp (atom + 1, "erver-name"))
|
||||
return SERVER_NAME;
|
||||
if (!strcasecmp (atom + 1, "erver-identifier"))
|
||||
return SERVER_IDENTIFIER;
|
||||
if (!strcasecmp (atom + 1, "elect-timeout"))
|
||||
return SELECT_TIMEOUT;
|
||||
if (!strcasecmp (atom + 1, "end"))
|
||||
return SEND;
|
||||
if (!strcasecmp (atom + 1, "cript"))
|
||||
return SCRIPT;
|
||||
break;
|
||||
case 't':
|
||||
if (!strcasecmp (atom + 1, "imestamp"))
|
||||
return TIMESTAMP;
|
||||
if (!strcasecmp (atom + 1, "imeout"))
|
||||
return TIMEOUT;
|
||||
if (!strcasecmp (atom + 1, "oken-ring"))
|
||||
return TOKEN_RING;
|
||||
break;
|
||||
case 'u':
|
||||
if (!strcasecmp (atom + 1, "id"))
|
||||
return UID;
|
||||
if (!strcasecmp (atom + 1, "ser-class"))
|
||||
return USER_CLASS;
|
||||
if (!strcasecmp (atom + 1, "se-host-decl-names"))
|
||||
return USE_HOST_DECL_NAMES;
|
||||
if (!strcasecmp (atom + 1, "nknown-clients"))
|
||||
return UNKNOWN_CLIENTS;
|
||||
break;
|
||||
case 'v':
|
||||
if (!strcasecmp (atom + 1, "endor-class"))
|
||||
return VENDOR_CLASS;
|
||||
break;
|
||||
case 'y':
|
||||
if (!strcasecmp (atom + 1, "iaddr"))
|
||||
return YIADDR;
|
||||
break;
|
||||
}
|
||||
return dfv;
|
||||
}
|
212
db.c
212
db.c
@ -1,212 +0,0 @@
|
||||
/* db.c
|
||||
|
||||
Persistent database management routines for DHCPD... */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996 The Internet Software Consortium.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of The Internet Software Consortium nor the names
|
||||
* of its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
|
||||
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This software has been written for the Internet Software Consortium
|
||||
* by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
||||
* Enterprises. To learn more about the Internet Software Consortium,
|
||||
* see ``http://www.vix.com/isc''. To learn more about Vixie
|
||||
* Enterprises, see ``http://www.vix.com''.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"$Id: db.c,v 1.8 1996/09/02 21:16:24 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
||||
FILE *db_file;
|
||||
|
||||
static int counting = 0;
|
||||
static int count = 0;
|
||||
TIME write_time;
|
||||
|
||||
/* Write the specified lease to the current lease database file. */
|
||||
|
||||
int write_lease (lease)
|
||||
struct lease *lease;
|
||||
{
|
||||
struct tm *t;
|
||||
char tbuf [64];
|
||||
int errors = 0;
|
||||
|
||||
if (counting)
|
||||
++count;
|
||||
errno = 0;
|
||||
fprintf (db_file, "lease %s {\n", piaddr (lease -> ip_addr));
|
||||
if (errno) {
|
||||
++errors;
|
||||
}
|
||||
|
||||
t = gmtime (&lease -> starts);
|
||||
sprintf (tbuf, "%d %d/%d/%d %02d:%02d:%02d;",
|
||||
t -> tm_wday, t -> tm_year + 1900,
|
||||
t -> tm_mon + 1, t -> tm_mday,
|
||||
t -> tm_hour, t -> tm_min, t -> tm_sec);
|
||||
errno = 0;
|
||||
fprintf (db_file, "\tstarts %s\n", tbuf);
|
||||
if (errno) {
|
||||
++errors;
|
||||
}
|
||||
|
||||
t = gmtime (&lease -> ends);
|
||||
sprintf (tbuf, "%d %d/%d/%d %02d:%02d:%02d;",
|
||||
t -> tm_wday, t -> tm_year + 1900,
|
||||
t -> tm_mon + 1, t -> tm_mday,
|
||||
t -> tm_hour, t -> tm_min, t -> tm_sec);
|
||||
errno = 0;
|
||||
fprintf (db_file, "\tends %s", tbuf);
|
||||
if (errno) {
|
||||
++errors;
|
||||
}
|
||||
|
||||
if (lease -> hardware_addr.hlen) {
|
||||
errno = 0;
|
||||
fprintf (db_file, "\n\thardware %s %s;",
|
||||
hardware_types [lease -> hardware_addr.htype],
|
||||
print_hw_addr (lease -> hardware_addr.htype,
|
||||
lease -> hardware_addr.hlen,
|
||||
lease -> hardware_addr.haddr));
|
||||
if (errno) {
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
if (lease -> uid_len) {
|
||||
int i;
|
||||
errno = 0;
|
||||
fprintf (db_file, "\n\tuid %x", lease -> uid [0]);
|
||||
if (errno) {
|
||||
++errors;
|
||||
}
|
||||
for (i = 1; i < lease -> uid_len; i++) {
|
||||
errno = 0;
|
||||
fprintf (db_file, ":%x", lease -> uid [i]);
|
||||
if (errno) {
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
putc (';', db_file);
|
||||
}
|
||||
if (lease -> flags & BOOTP_LEASE) {
|
||||
errno = 0;
|
||||
fprintf (db_file, "\n\tdynamic-bootp;");
|
||||
if (errno) {
|
||||
++errors;
|
||||
}
|
||||
}
|
||||
errno = 0;
|
||||
fputs ("\n}\n", db_file);
|
||||
if (errno) {
|
||||
++errors;
|
||||
}
|
||||
if (errors)
|
||||
note ("write_lease: unable to write lease %s",
|
||||
piaddr (lease -> ip_addr));
|
||||
return !errors;
|
||||
}
|
||||
|
||||
/* Commit any leases that have been written out... */
|
||||
|
||||
int commit_leases ()
|
||||
{
|
||||
/* Commit any outstanding writes to the lease database file.
|
||||
We need to do this even if we're rewriting the file below,
|
||||
just in case the rewrite fails. */
|
||||
if (fflush (db_file) == EOF) {
|
||||
note ("commit_leases: unable to commit: %m");
|
||||
return 0;
|
||||
}
|
||||
if (fsync (fileno (db_file)) < 0) {
|
||||
note ("commit_leases: unable to commit: %m");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If we've written more than a thousand leases or if
|
||||
we haven't rewritten the lease database in over an
|
||||
hour, rewrite it now. */
|
||||
if (count > 1000 || (count && cur_time - write_time > 3600)) {
|
||||
count = 0;
|
||||
write_time = cur_time;
|
||||
new_lease_file ();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void db_startup ()
|
||||
{
|
||||
/* Read in the existing lease file... */
|
||||
read_leases ();
|
||||
|
||||
new_lease_file ();
|
||||
}
|
||||
|
||||
void new_lease_file ()
|
||||
{
|
||||
char newfname [512];
|
||||
char backfname [512];
|
||||
TIME t;
|
||||
|
||||
/* If we already have an open database, close it. */
|
||||
if (db_file) {
|
||||
fclose (db_file);
|
||||
}
|
||||
|
||||
/* Make a temporary lease file... */
|
||||
time (&t);
|
||||
sprintf (newfname, "%s.%d", path_dhcpd_db, (int) (t & 32767));
|
||||
if ((db_file = fopen (newfname, "w")) == NULL) {
|
||||
error ("Can't start new lease file: %m");
|
||||
}
|
||||
|
||||
/* Write out all the leases that we know of... */
|
||||
counting = 0;
|
||||
write_leases ();
|
||||
|
||||
/* Get the old database out of the way... */
|
||||
sprintf (backfname, "%s~", path_dhcpd_db);
|
||||
if (unlink (backfname) < 0 && errno != ENOENT)
|
||||
error ("Can't remove old lease database backup %s: %m",
|
||||
backfname);
|
||||
if (link (path_dhcpd_db, backfname) < 0)
|
||||
error ("Can't backup lease database %s to %s: %m",
|
||||
path_dhcpd_db, backfname);
|
||||
|
||||
/* Move in the new file... */
|
||||
if (rename (newfname, path_dhcpd_db) < 0)
|
||||
error ("Can't install new lease database %s to %s: %m",
|
||||
newfname, path_dhcpd_db);
|
||||
|
||||
counting = 1;
|
||||
}
|
308
dhcpd.8
308
dhcpd.8
@ -1,308 +0,0 @@
|
||||
.\" dhcpd.8
|
||||
.\"
|
||||
.\" Copyright (c) 1995, 1996 The Internet Software Consortium.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\"
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\" 3. Neither the name of The Internet Software Consortium nor the names
|
||||
.\" of its contributors may be used to endorse or promote products derived
|
||||
.\" from this software without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
|
||||
.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
.\" DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
|
||||
.\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" This software has been written for the Internet Software Consortium
|
||||
.\" by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
||||
.\" Enterprises. To learn more about the Internet Software Consortium,
|
||||
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
|
||||
.\" Enterprises, see ``http://www.vix.com''.
|
||||
.TH dhcpd 8
|
||||
.SH NAME
|
||||
dhcpd - Dynamic Host Configuration Protocol Server
|
||||
.SH SYNOPSIS
|
||||
.B dhcpd
|
||||
[
|
||||
.B -p
|
||||
.I port
|
||||
]
|
||||
[
|
||||
.B -f
|
||||
]
|
||||
[
|
||||
.B -d
|
||||
]
|
||||
[
|
||||
.B -cf
|
||||
.I config-file
|
||||
]
|
||||
[
|
||||
.B -lf
|
||||
.I lease-file
|
||||
]
|
||||
[
|
||||
.I if0
|
||||
[
|
||||
.I ...ifN
|
||||
]
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
The Internet Software Consortium DHCP Server, dhcpd, implements the
|
||||
Dynamic Host Configuration Protocol (DHCP) and the Internet Bootstrap
|
||||
Protocol (BOOTP). DHCP allows hosts on a TCP/IP network to request
|
||||
and be assigned IP addresses, and also to discover information about
|
||||
the network to which they are attached. BOOTP provides similar
|
||||
functionality, with certain restrictions.
|
||||
.SH OPERATION
|
||||
.PP
|
||||
The DHCP protocol allows a host which is unknown to the network
|
||||
administrator to be automatically assigned a new IP address out of a
|
||||
pool of IP addresses for its network. In order for this to work, the
|
||||
network administrator allocates address pools in each subnet and
|
||||
enters them into the dhcpd.conf(5) file.
|
||||
.PP
|
||||
On startup, dhcpd reads the
|
||||
.IR dhcpd.conf
|
||||
file and stores a list of available addresses on each subnet in
|
||||
memory. When a client requests an address using the DHCP protocol,
|
||||
dhcpd allocates an address for it. Each client is assigned a lease,
|
||||
which expires after an amount of time chosen by the administrator (by
|
||||
default, one day). Before leases expire, the clients to which leases
|
||||
are assigned are expected to renew them in order to continue to use
|
||||
the addresses. Once a lease has expired, the client to which that
|
||||
lease was assigned is no longer permitted to use the leased IP
|
||||
address.
|
||||
.PP
|
||||
In order to keep track of leases across system reboots and server
|
||||
restarts, dhcpd keeps a list of leases it has assigned in the
|
||||
dhcpd.leases(5) file. Before dhcpd grants a lease to a host, it
|
||||
records the lease in this file and makes sure that the contents of the
|
||||
file are flushed to disk. This ensures that even in the event of a
|
||||
system crash, dhcpd will not forget about a lease that it has
|
||||
assigned. On startup, after reading the dhcpd.conf file, dhcpd
|
||||
reads the dhcpd.leases file to refresh its memory about what leases
|
||||
have been assigned.
|
||||
.PP
|
||||
New leases are appended to the end of the dhcpd.leases
|
||||
file. In order to prevent the file from becoming arbitrarily large,
|
||||
from time to time dhcpd creates a new dhcpd.leases file from its
|
||||
in-core lease database. Once this file has been written to disk, the
|
||||
old file is renamed
|
||||
.IR dhcpd.leases~ ,
|
||||
and the new file is renamed dhcpd.leases. If the system crashes in
|
||||
the middle of this process, whichever dhcpd.leases file remains will
|
||||
contain all the lease information, so there is no need for a special
|
||||
crash recovery process.
|
||||
.PP
|
||||
BOOTP support is also provided by this server. Unlike DHCP, the BOOTP
|
||||
protocol does not provide a protocol for recovering
|
||||
dynamically-assigned addresses once they are no longer needed. It is
|
||||
still possible to dynamically assign addresses to BOOTP clients, but
|
||||
some administrative process for reclaiming addresses is required. By
|
||||
default, leases are granted to BOOTP clients in perpetuity, although
|
||||
the network administrator may set an earlier cutoff date or a shorter
|
||||
lease length for BOOTP leases if that makes sense.
|
||||
.PP
|
||||
BOOTP clients may also be served in the old standard way, which is to
|
||||
simply provide a declaration in the dhcpd.conf file for each
|
||||
BOOTP client, permanently assigning an address to each client.
|
||||
.PP
|
||||
Whenever changes are made to the dhcpd.conf file, dhcpd must be
|
||||
restarted. To restart dhcpd, send a SIGTERM (signal 15) to the
|
||||
process ID contained in
|
||||
.IR RUNDIR/dhcpd.pid ,
|
||||
and then re-invoke dhcpd. Because the DHCP server database is not as
|
||||
lightweight as a BOOTP database, dhcpd does not automatically restart
|
||||
itself when it sees a change to the dhcpd.conf file.
|
||||
.SH COMMAND LINE
|
||||
.PP
|
||||
The names of the network interfaces on which dhcpd should listen for
|
||||
broadcasts may be specified on the command line. This should be done
|
||||
on systems where dhcpd is unable to identify non-broadcast interfaces,
|
||||
but should not be required on other systems. If no interface names
|
||||
are specified on the command line dhcpd will identify all network
|
||||
interfaces which are up, elimininating non-broadcast interfaces if
|
||||
possible, and listen for DHCP broadcasts on each interface.
|
||||
.PP
|
||||
If dhcpd should listen on a port other than the standard (port 67),
|
||||
the
|
||||
.B -p
|
||||
flag may used. It should be followed by the udp port number on which
|
||||
dhcpd should listen. This is mostly useful for debugging purposes.
|
||||
.PP
|
||||
To run dhcpd as a foreground process, rather than allowing it to run
|
||||
as a daemon in the background, the
|
||||
.B -f
|
||||
flag should be specified. This is useful when running dhcpd under a
|
||||
debugger, or when running it out of inittab on System V systems.
|
||||
.PP
|
||||
To have dhcpd log to the standard error descriptor, specify the
|
||||
.B -d
|
||||
flag. This can be useful for debugging, and also at sites where a
|
||||
complete log of all dhcp activity must be kept but syslogd is not
|
||||
reliable or otherwise cannot be used. Normally, dhcpd will log all
|
||||
output using the syslog(3) function with the log facility set to
|
||||
LOG_DAEMON.
|
||||
.PP
|
||||
Dhcpd can be made to use an alternate configuration file with the
|
||||
.B -cf
|
||||
flag, or an alternate lease file with the
|
||||
.B -lf
|
||||
flag. Because of the importance of using the same lease database at
|
||||
all times when running dhcpd in production, these options should be
|
||||
used \fBonly\fR for testing lease files or database files in a
|
||||
non-production environment.
|
||||
.SH CONFIGURATION
|
||||
The syntax of the dhcpd.conf(8) file is discussed seperately. This
|
||||
section should be used as an overview of the configuration process,
|
||||
and the dhcpd.conf(8) documentation should be consulted for detailed
|
||||
reference information.
|
||||
.PP
|
||||
.SH Subnets
|
||||
dhcpd needs to know the subnet numbers and netmasks of all subnets for
|
||||
which it will be providing service. In addition, in order to
|
||||
dynamically allocate addresses, it must be assigned one or more ranges
|
||||
of addresses on each subnet which it can in turn assign to client
|
||||
hosts as they boot. Thus, a very simple configuration providing DHCP
|
||||
support might look like this:
|
||||
.nf
|
||||
.sp 1
|
||||
subnet 239.252.197.0 netmask 255.255.255.0 {
|
||||
range 239.252.197.10 239.252.197.250;
|
||||
}
|
||||
.fi
|
||||
.PP
|
||||
Multiple address ranges may be specified like this:
|
||||
.nf
|
||||
.sp 1
|
||||
subnet 239.252.197.0 netmask 255.255.255.0 {
|
||||
range 239.252.197.10 239.252.197.107;
|
||||
range 239.252.197.113 239.252.197.250;
|
||||
}
|
||||
.fi
|
||||
.PP
|
||||
If a subnet will only be provided with BOOTP service and no dynamic
|
||||
address assignment, the range clause can be left out entirely, but the
|
||||
subnet statement must appear.
|
||||
.PP
|
||||
.SH Lease Lengths
|
||||
DHCP leases can be assigned almost any length from zero seconds to
|
||||
infinity. What lease length makes sense for any given subnet, or for
|
||||
any given installation, will vary depending on the kinds of hosts
|
||||
being served.
|
||||
.PP
|
||||
For example, in an office environment where systems are added from
|
||||
time to time and removed from time to time, but move relatively
|
||||
infrequently, it might make sense to allow lease times of a month of
|
||||
more. In a final test environment on a manufacturing floor, it may
|
||||
make more sense to assign a maximum lease length of 30 minutes -
|
||||
enough time to go through a simple test procedure on a network
|
||||
appliance before packaging it up for delivery.
|
||||
.PP
|
||||
It is possible to specify two lease lengths: the default length that
|
||||
will be assigned if a client doesn't ask for any particular lease
|
||||
length, and a maximum lease length. These are specified as clauses
|
||||
to the subnet command:
|
||||
.nf
|
||||
.sp 1
|
||||
subnet 239.252.197.0 netmask 255.255.255.0 {
|
||||
range 239.252.197.10 239.252.197.107;
|
||||
default-lease-time 600;
|
||||
max-lease-time 7200;
|
||||
|
|
||||
.fi
|
||||
.PP
|
||||
This particular subnet declaration specifies a default lease time of
|
||||
600 seconds (ten minutes), and a maximum lease time of 7200 seconds
|
||||
(two hours). Other common values would be 86400 (one day), 604800
|
||||
(one week) and 2592000 (30 days).
|
||||
.PP
|
||||
Each subnet need not have the same lease\(emin the case of an office
|
||||
environment and a manufacturing environment served by the same DHCP
|
||||
server, it might make sense to have widely disparate values for
|
||||
default and maximum lease times on each subnet.
|
||||
.SH BOOTP Support
|
||||
Each BOOTP client must be explicitly declared in the dhcpd.conf
|
||||
file. A very basic client declaration will specify the client
|
||||
network interface's hardware address and the IP address to assign to
|
||||
that client. If the client needs to be able to load a boot file from
|
||||
the server, that file's name must be specified. A simple bootp
|
||||
client declaration might look like this:
|
||||
.nf
|
||||
.sp 1
|
||||
host haagen {
|
||||
hardware ethernet 08:00:2b:4c:59:23;
|
||||
fixed-address 239.252.197.9;
|
||||
filename "/tftpboot/haagen.boot";
|
||||
}
|
||||
.fi
|
||||
.SH Options
|
||||
DHCP (and also BOOTP with Vendor Extensions) provide a mechanism
|
||||
whereby the server can provide the client with information about how
|
||||
to configure its network interface (e.g., subnet mask), and also how
|
||||
the client can access various network services (e.g., DNS, IP routers,
|
||||
and so on).
|
||||
.PP
|
||||
These options can be specified on a per-subnet basis, and, for BOOTP
|
||||
clients, also on a per-client basis. In the event that a BOOTP
|
||||
client declaration specifies options that are also specified in its
|
||||
subnet declaration, the options specified in the client declaration
|
||||
take precedence. An reasonably complete DHCP configuration might
|
||||
look something like this:
|
||||
.nf
|
||||
.sp 1
|
||||
subnet 239.252.197.0 netmask 255.255.255.0 {
|
||||
range 239.252.197.10 239.252.197.250;
|
||||
default-lease-time 600 max-lease-time 7200;
|
||||
option subnet-mask 255.255.255.0;
|
||||
option broadcast-address 239.252.197.255;
|
||||
option routers 239.252.197.1;
|
||||
option domain-name-servers 239.252.197.2, 239.252.197.3;
|
||||
option domain-name "isc.org";
|
||||
}
|
||||
.fi
|
||||
.PP
|
||||
A bootp host on that subnet that needs to be in a different domain and
|
||||
use a different name server might be declared as follows:
|
||||
.nf
|
||||
.sp 1
|
||||
host haagen hardware ethernet 08:00:2b:4c:59:23 {
|
||||
fixed-address 239.252.197.9;
|
||||
filename "/tftpboot/haagen.boot";
|
||||
option domain-name-servers 192.5.5.1;
|
||||
option domain-name "vix.com";
|
||||
}
|
||||
.fi
|
||||
.PP
|
||||
A more complete description of the dhcpd.conf file syntax is provided
|
||||
in dhcpd.conf(5).
|
||||
.SH FILES
|
||||
.B ETCDIR/dhcpd.conf, DBDIR/dhcpd.leases, RUNDIR/dhcpd.pid,
|
||||
.B DBDIR/dhcpd.leases~.
|
||||
.SH SEE ALSO
|
||||
dhclient(8), dhcrelay(8), dhcpd.conf(5), dhcpd.leases(5)
|
||||
.SH AUTHOR
|
||||
.B dhcpd(8)
|
||||
was written by Ted Lemon <mellon@vix.com>
|
||||
under a contract with Vixie Labs. Funding
|
||||
for this project was provided by the Internet Software Corporation.
|
||||
Information about the Internet Software Consortium can be found at
|
||||
.B http://www.isc.org/isc.
|
267
dhcpd.c
267
dhcpd.c
@ -1,267 +0,0 @@
|
||||
/* dhcpd.c
|
||||
|
||||
DHCP Server Daemon. */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996, 1997 The Internet Software Consortium.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of The Internet Software Consortium nor the names
|
||||
* of its contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
|
||||
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This software has been written for the Internet Software Consortium
|
||||
* by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
|
||||
* Enterprises. To learn more about the Internet Software Consortium,
|
||||
* see ``http://www.vix.com/isc''. To learn more about Vixie
|
||||
* Enterprises, see ``http://www.vix.com''.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char ocopyright[] =
|
||||
"$Id: dhcpd.c,v 1.38 1997/02/22 08:49:44 mellon Exp $ Copyright 1995, 1996 The Internet Software Consortium.";
|
||||
#endif
|
||||
|
||||
static char copyright[] =
|
||||
"Copyright 1995, 1996 The Internet Software Consortium.";
|
||||
static char arr [] = "All rights reserved.";
|
||||
static char message [] = "Internet Software Consortium DHCPD $Name: $";
|
||||
|
||||
#include "dhcpd.h"
|
||||
|
||||
static void usage PROTO ((void));
|
||||
|
||||
TIME cur_time;
|
||||
struct group root_group;
|
||||
|
||||
struct iaddr server_identifier;
|
||||
int server_identifier_matched;
|
||||
|
||||
#ifdef USE_FALLBACK
|
||||
struct interface_info fallback_interface;
|
||||
#endif
|
||||
|
||||
u_int16_t local_port;
|
||||
u_int16_t remote_port;
|
||||
|
||||
int log_priority;
|
||||
#ifdef DEBUG
|
||||
int log_perror = -1;
|
||||
#else
|
||||
int log_perror = 1;
|
||||
#endif
|
||||
|
||||
char *path_dhcpd_conf = _PATH_DHCPD_CONF;
|
||||
char *path_dhcpd_db = _PATH_DHCPD_DB;
|
||||
char *path_dhcpd_pid = _PATH_DHCPD_PID;
|
||||
|
||||
int main (argc, argv, envp)
|
||||
int argc;
|
||||
char **argv, **envp;
|
||||
{
|
||||
int i, status;
|
||||
struct servent *ent;
|
||||
char *s;
|
||||
#ifndef DEBUG
|
||||
int pidfilewritten = 0;
|
||||
int pid;
|
||||
char pbuf [20];
|
||||
int daemon = 1;
|
||||
#endif
|
||||
|
||||
/* Initially, log errors to stderr as well as to syslogd. */
|
||||
#ifdef SYSLOG_4_2
|
||||
openlog ("dhcpd", LOG_NDELAY);
|
||||
log_priority = DHCPD_LOG_FACILITY;
|
||||
#else
|
||||
openlog ("dhcpd", LOG_NDELAY, DHCPD_LOG_FACILITY);
|
||||
#endif
|
||||
|
||||
#ifndef DEBUG
|
||||
#ifndef SYSLOG_4_2
|
||||
setlogmask (LOG_UPTO (LOG_INFO));
|
||||
#endif
|
||||
#endif
|
||||
note (message);
|
||||
note (copyright);
|
||||
note (arr);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp (argv [i], "-p")) {
|
||||
if (++i == argc)
|
||||
usage ();
|
||||
for (s = argv [i]; *s; s++)
|
||||
if (!isdigit (*s))
|
||||
error ("%s: not a valid UDP port",
|
||||
argv [i]);
|
||||
status = atoi (argv [i]);
|
||||
if (status < 1 || status > 65535)
|
||||
error ("%s: not a valid UDP port",
|
||||
argv [i]);
|
||||
local_port = htons (status);
|
||||
debug ("binding to user-specified port %d",
|
||||
ntohs (local_port));
|
||||
} else if (!strcmp (argv [i], "-f")) {
|
||||
#ifndef DEBUG
|
||||
daemon = 0;
|
||||
#endif
|
||||
} else if (!strcmp (argv [i], "-d")) {
|
||||
#ifndef DEBUG
|
||||
daemon = 0;
|
||||
#endif
|
||||
log_perror = -1;
|
||||
} else if (!strcmp (argv [i], "-cf")) {
|
||||
if (++i == argc)
|
||||
usage ();
|
||||
path_dhcpd_conf = argv [i];
|
||||
} else if (!strcmp (argv [i], "-lf")) {
|
||||
if (++i == argc)
|
||||
usage ();
|
||||
path_dhcpd_db = argv [i];
|
||||
} else if (argv [i][0] == '-') {
|
||||
usage ();
|
||||
} else {
|
||||
struct interface_info *tmp =
|
||||
((struct interface_info *)
|
||||
dmalloc (sizeof *tmp, "get_interface_list"));
|
||||
if (!tmp)
|
||||
error ("Insufficient memory to %s %s",
|
||||
"record interface", argv [i]);
|
||||
memset (tmp, 0, sizeof *tmp);
|
||||
strcpy (tmp -> name, argv [i]);
|
||||
tmp -> next = interfaces;
|
||||
tmp -> flags = INTERFACE_REQUESTED;
|
||||
interfaces = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DEBUG
|
||||
if (daemon) {
|
||||
/* First part of becoming a daemon... */
|
||||
if ((pid = fork ()) < 0)
|
||||
error ("Can't fork daemon: %m");
|
||||
else if (pid)
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/* Read previous pid file. */
|
||||
if ((i = open (path_dhcpd_pid, O_RDONLY)) >= 0) {
|
||||
status = read (i, pbuf, (sizeof pbuf) - 1);
|
||||
close (i);
|
||||
pbuf [status] = 0;
|
||||
pid = atoi (pbuf);
|
||||
|
||||
/* If the previous server process is not still running,
|
||||
write a new pid file immediately. */
|
||||
if (pid && kill (pid, 0) < 0) {
|
||||
unlink (path_dhcpd_pid);
|
||||
if ((i = open (path_dhcpd_pid,
|
||||
O_WRONLY | O_CREAT, 0640)) >= 0) {
|
||||
sprintf (pbuf, "%d\n", (int)getpid ());
|
||||
write (i, pbuf, strlen (pbuf));
|
||||
close (i);
|
||||
pidfilewritten = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* !DEBUG */
|
||||
|
||||
/* Default to the DHCP/BOOTP port. */
|
||||
if (!local_port)
|
||||
{
|
||||
ent = getservbyname ("dhcp", "udp");
|
||||
if (!ent)
|
||||
local_port = htons (67);
|
||||
else
|
||||
local_port = ent -> s_port;
|
||||
endservent ();
|
||||
}
|
||||
|
||||
remote_port = htons (ntohs (local_port) + 1);
|
||||
|
||||
/* Get the current time... */
|
||||
GET_TIME (&cur_time);
|
||||
|
||||
/* Read the dhcpd.conf file... */
|
||||
if (!readconf ())
|
||||
error ("Configuration file errors encountered -- exiting");
|
||||
|
||||
/* Start up the database... */
|
||||
db_startup ();
|
||||
|
||||
/* Discover all the network interfaces and initialize them. */
|
||||
discover_interfaces (1);
|
||||
|
||||
#ifndef DEBUG
|
||||
/* If we were requested to log to stdout on the command line,
|
||||
keep doing so; otherwise, stop. */
|
||||
if (log_perror == -1)
|
||||
log_perror = 1;
|
||||
else
|
||||
log_perror = 0;
|
||||
|
||||
if (daemon) {
|
||||
/* Become session leader and get pid... */
|
||||
close (0);
|
||||
close (1);
|
||||
close (2);
|
||||
pid = setsid ();
|
||||
}
|
||||
|
||||
/* If we didn't write the pid file earlier because we found a
|
||||
process running the logged pid, but we made it to here,
|
||||
meaning nothing is listening on the bootp port, then write
|
||||
the pid file out - what's in it now is bogus anyway. */
|
||||
if (!pidfilewritten) {
|
||||
unlink (path_dhcpd_pid);
|
||||
if ((i = open (path_dhcpd_pid,
|
||||
O_WRONLY | O_CREAT, 0640)) >= 0) {
|
||||
sprintf (pbuf, "%d\n", (int)getpid ());
|
||||
write (i, pbuf, strlen (pbuf));
|
||||
close (i);
|
||||
pidfilewritten = 1;
|
||||
}
|
||||
}
|
||||
#endif /* !DEBUG */
|
||||
|
||||
/* Receive packets and dispatch them... */
|
||||
dispatch (1);
|
||||
|
||||
/* Not reached */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Print usage message. */
|
||||
|
||||
static void usage ()
|
||||
{
|
||||
error ("Usage: dhcpd [-p <UDP port #>] [-d] [-f] [-cf config-file]%s",
|
||||
"\n [-lf lease-file] [if0 [...ifN]]");
|
||||
}
|
||||
|
||||
void cleanup ()
|
||||
{
|
||||
}
|
128
dhcpd.conf
128
dhcpd.conf
@ -1,128 +0,0 @@
|
||||
# dhcpd.conf
|
||||
#
|
||||
# Configuration file for ISC dhcpd
|
||||
#
|
||||
|
||||
# Hosts with more than one interface MUST specify a ``server-identifier'',
|
||||
# which should be the IP address of the server's primary network interface,
|
||||
# or if there is no interface that can be described that way, at least an
|
||||
# interface whose address isn't likely to change.
|
||||
|
||||
server-identifier toccata.fugue.com;
|
||||
|
||||
# option definitions common to all supported networks...
|
||||
option domain-name "fugue.com";
|
||||
option domain-name-servers toccata.fugue.com;
|
||||
|
||||
# Shared network declaration is used to group subnets which share the same
|
||||
# physical network together. The name is specified so that the shared
|
||||
# network can be referred to in log messages - it serves no other function.
|
||||
|
||||
shared-network FUGUE {
|
||||
|
||||
# option definitions common to this shared network.
|
||||
option subnet-mask 255.255.255.224;
|
||||
default-lease-time 600;
|
||||
max-lease-time 7200;
|
||||
|
||||
# One of the two IP subnets that share this physical network
|
||||
#
|
||||
# Address ranges can be specified for each subnet attached to
|
||||
# a shared network. Since these subnets share the same physical
|
||||
# network, addresses are pooled together, and assignments are made
|
||||
# without regard to the actual subnet. If the optional dynamic-bootp
|
||||
# keyword is given in the address range declaration, then addresses
|
||||
# in that range can be assigned either with the DHCP protocol or the
|
||||
# BOOTP protocol; otherwise, only DHCP clients will have addresses
|
||||
# allocated from the address range.
|
||||
#
|
||||
# Note that each IP subnet can have its own options specific to that subnet.
|
||||
# options that aren't specified in the subnet are taken from the shared
|
||||
# network (if any) and then from the global option list.
|
||||
|
||||
subnet 204.254.239.0 netmask 255.255.255.224 {
|
||||
range 204.254.239.10 204.254.239.20;
|
||||
option broadcast-address 204.254.239.31;
|
||||
option routers prelude.fugue.com;
|
||||
}
|
||||
|
||||
# The other subnet that shares this physical network
|
||||
subnet 204.254.239.32 netmask 255.255.255.224 {
|
||||
range dynamic-bootp 204.254.239.10 204.254.239.20;
|
||||
option broadcast-address 204.254.239.31;
|
||||
option routers snarg.fugue.com;
|
||||
}
|
||||
}
|
||||
|
||||
# IP subnets that are alone on their physical wire should be declared by
|
||||
# themselves. ISC dhcpd may still refer to them as shared networks in
|
||||
# log messages, but this is simply an artifact of the underlying data
|
||||
# structures.
|
||||
#
|
||||
# Note that options can be specified in the subnet declaration which
|
||||
# supersede the global options specified earlier.
|
||||
|
||||
subnet 192.5.5.0 netmask 255.255.255.224 {
|
||||
range 192.5.5.26 192.5.5.30;
|
||||
option name-servers bb.home.vix.com, gw.home.vix.com;
|
||||
option domain-name "vix.com";
|
||||
option routers 192.5.5.1;
|
||||
option subnet-mask 255.255.255.224;
|
||||
option broadcast-address 192.5.5.31;
|
||||
default-lease-time 600;
|
||||
max-lease-time 7200;
|
||||
}
|
||||
|
||||
# Hosts which require special configuration options can be listed in
|
||||
# host statements. If no address is specified, the address will be
|
||||
# allocated dynamically (if possible), but the host-specific information
|
||||
# will still come from the host declaration.
|
||||
|
||||
host passacaglia {
|
||||
hardware ethernet 0:0:c0:5d:bd:95;
|
||||
filename "vmunix.passacaglia";
|
||||
server-name "toccata.fugue.com";
|
||||
}
|
||||
|
||||
# Fixed IP addresses can also be specified for hosts. These addresses
|
||||
# should not also be listed as being available for dynamic assignment.
|
||||
# Hosts for which fixed IP addresses have been specified can boot using
|
||||
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
|
||||
# be booted with DHCP, unless there is an address range on the subnet
|
||||
# to which a BOOTP client is connected which has the dynamic-bootp flag
|
||||
# set.
|
||||
host fantasia {
|
||||
hardware ethernet 08:00:07:26:c0:a5;
|
||||
fixed-address fantasia.fugue.com;
|
||||
}
|
||||
|
||||
# If a DHCP or BOOTP client is mobile and might be connected to a variety
|
||||
# of networks, more than one fixed address for that host can be specified.
|
||||
# Hosts can have fixed addresses on some networks, but receive dynamically
|
||||
# allocated address on other subnets; in order to support this, a host
|
||||
# declaration for that client must be given which does not have a fixed
|
||||
# address. If a client should get different parameters depending on
|
||||
# what subnet it boots on, host declarations for each such network should
|
||||
# be given. Finally, if a domain name is given for a host's fixed address
|
||||
# and that domain name evaluates to more than one address, the address
|
||||
# corresponding to the network to which the client is attached, if any,
|
||||
# will be assigned.
|
||||
host confusia {
|
||||
hardware ethernet 02:03:04:05:06:07;
|
||||
fixed-address confusia-1.fugue.com, confusia-2.fugue.com;
|
||||
filename "vmunix.confusia";
|
||||
server-name "toccata.fugue.com";
|
||||
}
|
||||
|
||||
host confusia {
|
||||
hardware ethernet 02:03:04:05:06:07;
|
||||
fixed-address confusia-3.fugue.com;
|
||||
filename "vmunix.confusia";
|
||||
server-name "snarg.fugue.com";
|
||||
}
|
||||
|
||||
host confusia {
|
||||
hardware ethernet 02:03:04:05:06:07;
|
||||
filename "vmunix.confusia";
|
||||
server-name "bb.home.vix.com";
|
||||
}
|
1081
dhcpd.conf.5
1081
dhcpd.conf.5
File diff suppressed because it is too large
Load Diff
1254
dhcpd.conf.cat5
1254
dhcpd.conf.cat5
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user