设备需求:
DHCP-server RHEL5.5 eth0: 192.168.10.66/24 (VMWARE19)
gw: 192.168.10.1
-----------------------------------------------------------------
DHCP-Relay RHEL5.5 eth0: 192.168.10.1/24 (VMWARE19)
eth1: 192.168.30.1/24 (VMWARE3)
eth2: 192.168.50.1/24 (VMWARE5)
eth3: 192.168.70.1/24 (VMWARE7)
-----------------------------------------------------------------
XP一台作为测试用机器:分别调为VMWARE3/5/7,可以分别获取192.168.30.0/24
192.168.50.0/24 192.168.70.0/24 网段中的IP地址
====================================================
步骤一:(在DHCP-Server上的配置)
[[email protected] ~]#
[[email protected] ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:18:AA:A3
inet addr:192.168.10.66 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe18:aaa3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6390 errors:0 dropped:0 overruns:0 frame:0
TX packets:130 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5659813 (5.3 MiB) TX bytes:15820 (15.4 KiB)
Interrupt:59 Base address:0x2024
[[email protected] ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.10.1 0.0.0.0 UG 0 0 0 eth0
=========================================================
[ro[email protected] ~]# rpm -q dhcp (如果未安装,请先安装DHCP服务器rpm包)
dhcp-3.0.5-23.el5
[[email protected] ~]# cat /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample > /etc/dhcpd.conf
[[email protected] ~]# vi /etc/dhcpd.conf (DHCP配置如下)
ddns-update-style interim;
ignore client-updates;
option subnet-mask 255.255.255.0;
option domain-name-servers 202.106.0.20,8.8.8.8;
option time-offset -18000; # Eastern Standard Time
default-lease-time 21600;
max-lease-time 43200;
subnet 192.168.10.0 netmask 255.255.255.0 {
}
subnet 192.168.30.0 netmask 255.255.255.0 {
option routers 192.168.30.1;
range dynamic-bootp 192.168.30.128 192.168.30.254;
}
subnet 192.168.50.0 netmask 255.255.255.0 {
option routers 192.168.50.1;
range dynamic-bootp 192.168.50.128 192.168.50.254;
}
subnet 192.168.70.0 netmask 255.255.255.0 {
option routers 192.168.70.1;
range dynamic-bootp 192.168.70.128 192.168.70.254;
}
=============================================
[[email protected] ~]# service dhcpd start
启动 dhcpd: [确定]
[[email protected] ~]# chkconfig dhcpd on
=============================================
步骤二:(在DHCP-Relay上的配置)
-------------------------------------------------------------------
[[email protected] ~]# ip addr show
2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:cf:0c:9c brd ff:ff:ff:ff:ff:ff
inet 192.168.10.1/24 brd 192.168.10.255 scope global eth0
inet6 fe80::20c:29ff:fecf:c9c/64 scope link
valid_lft forever preferred_lft forever
3: eth1: mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:cf:0c:a6 brd ff:ff:ff:ff:ff:ff
inet 192.168.30.1/24 brd 192.168.30.255 scope global eth1
inet6 fe80::20c:29ff:fecf:ca6/64 scope link
valid_lft forever preferred_lft forever
4: eth2: mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:cf:0c:b0 brd ff:ff:ff:ff:ff:ff
inet 192.168.50.1/24 brd 192.168.50.255 scope global eth2
inet6 fe80::20c:29ff:fecf:cb0/64 scope link
valid_lft forever preferred_lft forever
5: eth3: mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:cf:0c:ba brd ff:ff:ff:ff:ff:ff
inet 192.168.70.1/24 brd 192.168.70.255 scope global eth3
inet6 fe80::20c:29ff:fecf:cba/64 scope link
valid_lft forever preferred_lft forever
----------------------------------------------------------------------
[[email protected] ~]# rpm -q dhcp (如果未安装,请先安装DHCP服务器rpm包)
dhcp-3.0.5-23.el5
[[email protected] ~]# vi /etc/sysctl.conf
7 net.ipv4.ip_forward = 1 //此处将0改为1,开启路由转发功能
[[email protected] ~]# sysctl -p //使上面修改的内核参数生效
[[email protected] ~]# vi /etc/sysconfig/dhcrelay
# Command line options here
INTERFACES="eth0 eth1 eth2 eth3" //此处指定DHCP-RELAY要侦听的网卡名称
DHCPSERVERS="192.168.10.66" //此处指定DHCP服务器的IP地址
=======================================================
[[email protected] ~]# service dhcrelay start
启动 dhcrelay: [确定]
[[email protected] ~]# chkconfig dhcrelay on
[[email protected] ~]# dhcrelay 192.168.10.66 //如在虚拟机中演示本实验,本条命令必须要执行,
//表示立即在本机开启中继对DHCP服务的转发功能
Internet Systems Consortium DHCP Relay Agent V3.0.5-RedHat
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
Listening on LPF/eth3/00:0c:29:cf:0c:ba
Sending on LPF/eth3/00:0c:29:cf:0c:ba
Listening on LPF/eth2/00:0c:29:cf:0c:b0
Sending on LPF/eth2/00:0c:29:cf:0c:b0
Listening on LPF/eth1/00:0c:29:cf:0c:a6
Sending on LPF/eth1/00:0c:29:cf:0c:a6
Listening on LPF/eth0/00:0c:29:cf:0c:9c
Sending on LPF/eth0/00:0c:29:cf:0c:9c
Sending on Socket/fallback
=================================================
步骤三:
用XP来进行测试
,multicast,up,lower_up>,multicast,up,lower_up>,multicast,up,lower_up>,multicast,up,lower_up>