DHCP

所需软件:
dhcp-3.0.5-******

DHCP需要给予的是:IP 掩码 网关 DNS
配置文件是 /etc/dhcpd.conf
软件装好后,这个配置文件是空的,但是系统有个参照文件在
/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample中,直接把这个文件 复制为 /etc/dhcpd.conf就行老,直接更改这个文件就非常和谐老。

ddns-update-style interim; none      
ignore client-updates;
#这上面是整体配置,下面是局部配置

subnet 192.168.0.0 netmask 255.255.255.0 {

# --- default gateway
        option routers                  192.168.0.1;
        option subnet-mask              255.255.255.0;

        option nis-domain               "domain.org";
        option domain-name              "domain.org";
        option domain-name-servers      192.168.1.1;

        option time-offset              -18000; # Eastern Standard Time
#       option ntp-servers              192.168.1.1;
#       option netbios-name-servers     192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
#       option netbios-node-type 2;

        range dynamic-bootp 192.168.0.128 192.168.0.254;
        default-lease-time 21600;
        max-lease-time 43200;

       
        #下面是静态IP的设置
        # we want the nameserver to appear at a fixed address

        host ns {
                next-server marvin.redhat.com;
                hardware ethernet 12:34:56:78:AB:CD;
                fixed-address 207.175.42.254;
        }
}

ddns-update-style interim; none

定义所支持的DNS动态更新类型 ,none表示不支持)
这个参数是必须的,而且必须放在第一行

ignore client-updates
忽略客户端更新

subnet 192.168.0.0 netmask 255.255.255.0
声明分配那个网段和掩码

option routers
设置客户端网关的

option subnet-mask
设置客户端子网掩码

option domain-name-servers
设置客户端的DNS,多个DNS需要以,(逗号)分隔

range dynamic-bootp
设置声明网段中具体那个范围分配给客户端

default-lease-time
设置IP租约时间,单位是 “妙“

max-lease-time
设置IP租约最大值
hardware ethernet
设置客户端网卡MAC

fixed-address 207.175.42.254
这个客户端MAC需要邦定的IP

每个设置值后面都要跟分号 “;” 当DHCP启动起来后,在 租约数据库文件 /var/lib/dhcpd/dhcpd.leases
里面就会有记录,最开始是没有记录的

例 1:绑定多个静态IP
声明网段192.168.0.0
路由网关为 0.1 
DNS   0.5
www   0.4
邮件  0.3
子网掩码为255.255.255.0
 
DHCP地址池为
0.1000.200

ddns-update-style interim;none;
ignore client-updates;

subnet 192.168.0.0 netmask 255.255.255.0 {

# --- default gateway
        option routers                  192.168.0.1;
        option subnet-mask              255.255.255.0;

        option nis-domain               "domain.org";
        option domain-name              "domain.org";
        option domain-name-servers      192.168.0.5;

        option time-offset              -18000; # Eastern Standard Time
#       option ntp-servers              192.168.1.1;
#       option netbios-name-servers     192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
#       option netbios-node-type 2;

        range dynamic-bootp 192.168.0.100 192.168.0.200;
        default-lease-time 21600;
        max-lease-time 43200;

        # we want the nameserver to appear at a fixed address
        host DNS {
                hardware ethernet 00:12:56:78:AB:CD;
                fixed-address 192.168.0.5;
        }
       
        host www {

                hardware ethernet 00:45:56:AD:22:33;
                fixed-address 192.168.0.4;
        }

        host mail {
                hardware ethernet 00:CA:56:AD:27:89;
                fixed-address 192.168.0.3;
        }

}

如果只想分配IP和掩码,那就把其他的选项注释掉就可以老 例 2:设置多个网段分配
比如现在主机是400台,但是在192.168.1.0这个网段只能分配254个IP,那么就要增加网段,就是多作用域

拓扑图:


用DHCP服务器的两张网卡连接两个网段,并且配置好DHCP两张网卡自己相应的IP地址,在配置文件中设置两个声明就行了
ddns-update-style interim;none;
ignore client-updates;

subnet 192.168.0.0 netmask 255.255.255.0 {

        option routers                  192.168.0.1;
        option subnet-mask              255.255.255.0;
        option domain-name-servers      192.168.0.5;

        range dynamic-bootp 192.168.0.100 192.168.0.200;
        default-lease-time 21600;
        max-lease-time 43200;

}

subnet 192.168.1.0 netmask 255.255.255.0 {

        option routers                  192.168.1.1;
        option subnet-mask              255.255.255.0;
        option domain-name-servers      192.168.1.5;

        range dynamic-bootp 192.168.1.100 192.168.1.200;
        default-lease-time 21600;
        max-lease-time 43200;
}

图1


图2



如图1和图2所示,
    在客户端设备和DHCP服务器不再同一广播域内的时候,中间设备即路有器(路有功能的设备,比如路由和三层交换机)必须要能够转发这种广播包,具体到cisco的设备上,则启用 ip helper-address命令,来实现这种中继功能
ip helper-address的具体介绍看
(http://www.net130.com/CMS/Pub/special/special_dhcp/special_dhcp_cisco/2006_12_26_71053.htm)


ip helper-address
是把本网段的UDP广播转到另一个网段的指定的机器上,而且转发到另一个网端是以 unicast(单播)的方式进行的







本文出自 “eo” 博客,谢绝转载!

你可能感兴趣的:(职场,DHCP,休闲)