文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>第2部分 范例配置文件分析--2

第2部分 范例配置文件分析--2

时间:2007-06-20  来源:liufirst

以 # 开头的行是注释语句。下面一段一段看这个文件中包含语句的意义。

# dhcpd.conf

#

# Sample configuration file for ISC dhcpd

# option definitions common to all supported networks...

option domain-name "example.org";

option domain-name-servers ns1.example.org, ns2.example.org;

 

default-lease-time 600;

max-lease-time 7200;

 

# If this DHCP server is the official DHCP server for the local

# network, the authoritative directive should be uncommented.

#authoritative;

 

# Use this to send dhcp log messages to a different log file (you also

# have to hack syslog.conf to complete the redirection).

log-facility local7;

这一段属于配置文件的“顶部”,它里面定义的属性对于整个dhcpd服务器都有效,如果某个子网、多子网网络或者主机有其它需要的定义,可以在相应的地方再配置这些参数,那些地方的参数优先值比这里高。

option domain-name "example.org";

option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 600;

max-lease-time 7200;

log-facility local7;

这几句的意思:domain-name配置(客户端的)域名为example.org,它用在客户端的hostname后,组成一个完整的主机名,例如,一个客户端的hostname是test,那么它的完整域名就是test.example.org。

domain-name-servers 配置客户端的域名服务器名称,可以多配几个,都会传送给客户端(就是客户端的DNS项,只见过配2个的,没见过更多的)

default-lease-time配置默认租约长度,以秒为单位。

max-lease-time最大租约长度,不知道有什么用(在WIN下似乎没有这个概念)

log-facility local7;设置日志记录的设备,这里使用local7。

注意还有一句注释的语句,它可能是非常有用的:

#authoritative;

前面有这个语句使用的条件:如果这个DHCP服务器对于这个子网是官方的,就不应该注释这一句。也就是说,这个DHCP服务器不是实验的,对于这个网络实际是真正要使用的,就应该有这一句。

以下加入一个子网:

# No service will be given on this subnet, but declaring it helps the

# DHCP server to understand the network topology.

 

subnet 10.152.187.0 netmask 255.255.255.0 {

}

前面的注释说,即使对这个子网不分配地址,也应该加入这个子网,这样有利于帮助DHCP服务器理解网络拓扑。(感觉通常这个子网都是DHCP服务器所在的子网)

下面加入一个最基本的子网,DHCP服务器为这个子网分配地址,这是DHCP服务器最常见、最简单的使用方法。

# This is a very basic subnet declaration.

 

subnet 10.254.239.0 netmask 255.255.255.224 {

  range 10.254.239.10 10.254.239.20;

  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;

}

关于subnet的使用,在man dhcpd.conf里有很详细的说明,这一段确定一个子网,网段号是10.254.239.0,子网掩码是255.255.255.224,就是说这一段最大只会有32个地址;下面的range语句,指定了可分配地址的最小值和最大值。

 

但是其中的option routers的说明如下:

option routers ip-address [, ip-address...  ];

 

          The  routers  option  specifies  a  list  of IP addresses for routers on the client’s subnet.  Routers should be listed in order of preference.

可以指定多个网关!网关要依照性能按顺序写。(在实际的配置中,好像很少用到多个网关,而且客户端如何处理多网关呢?)

通常这样一段就够用了,对于一个小的企业,一个子网的情况,这个DHCP服务器已经完成,后面的部分删去就可以了!

这一段是设置BOOTP用户的。前面的注释里说,并不推荐这种使用。

# This declaration allows BOOTP clients to get dynamic addresses,

# which we don't really recommend.

 

subnet 10.254.239.32 netmask 255.255.255.224 {

  range dynamic-bootp 10.254.239.40 10.254.239.60;

  option broadcast-address 10.254.239.31;

  option routers rtr-239-32-1.example.org;

}

 

关于BOOTP客户的简单说明:

英文原义:Bootstrap Protocol

中文释义:自举协议

注解:该协议是一个基于TCP/IP协议的协议,它可以让无盘站从一个中心服务器上获得IP地址,为局域网中的无盘工作站分配动态IP地址,并不需要每个用户去设置静态IP地址。使用BOOTP协议的时候,一般包括Bootstrap Protocol Server(自举协议服务端)和Bootstrap Protocol Client(自举协议客户端)两部分。

有关range语句的说明:

       range [ dynamic-bootp ] low-address [ high-address];

 

       任何能分配的子网都最少要有一个range语句才能分配地址。它确定能分配的最小地址和最大地址,所有的IP地址都应该在这个子网中。dynamic-bootp 标志指定如果地址指定范围内会动态分配BOOTP客户端,就像DHCP客户端一样。如果只指定了一个地址,那么认为是最大地址(high-address)被省略了。

有些语句以option开头,有些不以,它们的区别:

有些参数以option 关键字开头,有些不。以option 关键字开头的语句对应实际的DHCP选项,不以option关键字开头的选项控制服务端(例如,租期) 或客户端的选项,它们不属于DHCP协议中规定的内容(例如,服务器名或文件名)

这一段的两个option语句定义了子网的广播地址和网关。

 

下面一段与前面稍微有些区别:

# A slightly different configuration for an internal subnet.

subnet 10.5.5.0 netmask 255.255.255.224 {

  range 10.5.5.26 10.5.5.30;

  option domain-name-servers ns1.internal.example.org;

  option domain-name "internal.example.org";

  option routers 10.5.5.1;

  option broadcast-address 10.5.5.31;

  default-lease-time 600;

  max-lease-time 7200;

}

这一段中有option domain-name-servers、option domain-name  default-lease-time 和max-lease-time四个选项在全局范围内已经定义过了,这里的定义只在本子网范围内有效。

下面一段是固定地址的设定

# 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";

}

前面的注释说,有特殊配置的主机可以使用host语句来配置,如果在host语句中没有fixed-address语句,(如果可能)那么将会动态分配给主机地址,但是host语句中指定的信息会作用到指定的主机上。

这里指定了filename和server-name,指定了指定主机启动时将要下载的启动文件名称和服务器。

下面这一段给出了给某个主机指定固定地址的例子:

# 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;

}

前面的注释说:可以使用host语句来指定固定IP地址,这个地址不一定要是动态分配部分的地址。使用host语句和固定IP地址的主机可以是BOOTP客户或者是DHCP客户,但是没有固定IP地址(fixed-address)的用户只能是DHCP用户,除非在range语句里说明是BOOTP用户(使用dynamic-bootp标志,见前面range部分)。

相关阅读 更多 +
排行榜 更多 +
章鱼小丸子游戏中文版下载

章鱼小丸子游戏中文版下载

模拟经营 下载
dazzly绚石工坊中文最新版下载

dazzly绚石工坊中文最新版下载

休闲益智 下载
木筏漂流游戏下载

木筏漂流游戏下载

休闲益智 下载