dhcp伺服器設定ip:
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=172.17.17.2
NETMASK=255.255.255.0
GATEWAY=172.17.17.1
[root@localhost ~]# service network restart
正在關閉接口 eth0: [确定]
關閉環回接口: [确定]
彈出環回接口: [确定]
彈出界面 eth0: [确定]
[root@localhost ~]# ifconfig eth0
安裝DHCP:
[root@localhost ~]# mount /dev/cdrom /mnt
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@localhost ~]# yum install dhcp*
主配置檔案:
[root@localhost ~]# vim /etc/dhcpd.conf
[root@localhost ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhc
dhclient-eth0.conf dhcp6s.conf
dhcp6c.conf dhcpd.conf
[root@localhost ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
cp:是否覆寫“/etc/dhcpd.conf”? y
ddns-update-style interim;
ignore client-updates;
subnet 172.17.17.0 netmask 255.255.255.0 {
# --- default gateway
option routers 172.17.17.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
range dynamic-bootp 172.17.17.1 172.17.17.100;
default-lease-time 21600;
max-lease-time 43200;
啟動dhcp:[root@localhost ~]# service dhcpd start
啟動 dhcpd: [确定]
[root@localhost ~]#
中繼代理的設定
設定ip:
eth0: 172.17.17.17.1 255.255.255.0
eth1: 192.168.1.1 255.255.255.0
eth2: 192.168.2.1 255.255.255.0
service network restart
安裝dhcp:
配置檔案:
[root@localhost ~]#vim /etc/sysconfig/dhcrelay
INTERFACES="eth0 eth1 eth2"
DHCPSERVERS="172.17.17.2"
啟動dhcrelay:
[root@localhost ~]#service dhcrelay start
啟動 dhcrelay [确定]
設定ip轉發:
[root@localhost ~]# vim /etc/sysctl.conf
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
[root@localhost ~]# sysctl -p
用戶端測試:
[root@localhost ~]# dhclient eth0
Internet Systems Consortium DHCP Client 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/eth0/00:0c:29:0a:35:35
Sending on LPF/eth0/00:0c:29:0a:35:35
Sending on Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
DHCPOFFER from 172.17.17.2
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPACK from 172.17.17.2
bound to 172.17.17.99-- renewal in 10526 seconds.