(1)简单实现DHCP多作用域
对于多作用域的配置,必须保证DHCP服务器能够侦听所有子网客户机的请求信息,下面将讲解配置多作用域的基本方法,为DHCP添加多个网卡连接每个子网,并发布多个作用域的声明。
注意:划分子网时,如果选择直接配置多作用域实现动态IP分配的任务,则必须要为DHCP服务器添加多块网卡,并配置多个IP地址,否则DHCP服务器只能分配与其现有网卡IP地址对应网段的作用域。
采用双网卡实现两个作用域
1)网卡配置IP地址
DHCP服务器有多块网卡时,需要使用ifconfig命令为每块网卡配置独立的IP地址,但要注意,IP地址配置的网段要与DHCP服务器发布的作用域对应哈~
ifconfig eth0 192.168.2.1 netmask 255.255.255.0
ifconfig eth1 192.168.3.1 netmask 255.255.255.0
2)编辑dhcpd.conf主配置文件
当DHCP服务器网络环境搭建完毕后,可以编辑dhcpd.conf主配置文件完成多作用域的设置。
ddns-update-style none;
ignore client-updates;
subnet 192.168.2.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.2.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.2.2;
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.2.50 192.168.2.250;
default-lease-time 21600;
max-lease-time 43200;
# 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;
}
}
subnet 192.168.3.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.3.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.2.2;
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.3.50 192.168.3.250;
default-lease-time 21600;
max-lease-time 43200;
max-lease-time 43200;
}
保存退出。
3)测试验证
重启DHCP服务后检查系统日志,检测配置是否成功,使用tail命令动态显示日志信息。
tail -F /etc/log/messages
经过设置,对于DHCP服务器将通过eth0和eth1两块网卡侦听客户机的请求,并发送相应的回应。
Jan 19 16:02:51 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da via eth1
Jan 19 16:02:51 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da via eth0
Jan 19 16:02:52 rhel5 dhcpd: DHCPOFFER . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:52 rhel5 dhcpd: DHCPOFFER . 192.168.2.250 to 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:52 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:52 rhel5 dhcpd: DHCPACK . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:52 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth0: ignored (not authoritative).
Jan 19 16:02:53 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:53 rhel5 dhcpd: DHCPOFFER . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:53 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:53 rhel5 dhcpd: DHCPOFFER . 192.168.2.250 to 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:53 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:53 rhel5 dhcpd: DHCPACK . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:53 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth0: ignored (not authoritative).
Jan 19 16:02:54 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:54 rhel5 dhcpd: DHCPOFFER . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:54 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:54 rhel5 dhcpd: DHCPOFFER . 192.168.2.250 to 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:54 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:54 rhel5 dhcpd: DHCPACK . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:54 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth0: ignored (not authoritative).
Jan 19 16:02:55 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:55 rhel5 dhcpd: DHCPOFFER . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:55 rhel5 dhcpd: DHCPDISCOVER from 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:55 rhel5 dhcpd: DHCPOFFER . 192.168.2.250 to 00:19:21:bd:a3:da (mis) via eth0
Jan 19 16:02:55 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:55 rhel5 dhcpd: DHCPACK . 192.168.3.250 to 00:19:21:bd:a3:da (mis) via eth1
Jan 19 16:02:55 rhel5 dhcpd: DHCPREQUEST for 192.168.3.250 (192.168.3.1) from 00:19:21:bd:a3:da (mis) via eth0: ignored (not authoritative).