参考

1.http://chenxizhuimeng.blog.51cto.com/2516314/505986

2.http://dreamfire.blog.51cto.com/418026/178680

做试验学习搭建dhcp服务器;

服务器系统是centOS6,双网卡,

内网卡:eth1  /IP 172.16.10.1  Bcast:172.16.255.255  Mask:255.255.0.0
外网卡:eth0 /IP  192.168.2.15  Bcast:192.168.255.255  Mask:255.255.0.0
 

1.先配置好网卡 使之能连通外网

[root@mydhcpgw /]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
HWADDR="00:14:D5:EF:19:66"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE=Ethernet
BOOTPROTO=none
PREFIX=16
IPADDR=172.16.10.1
NETMASK=255.255.255.0
#GATEWAY=172.16.10.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
 

[root@mydhcpgw /]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
WADDR="00:14:D5:EF:19:64"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE=Ethernet
BOOTPROTO=none
PREFIX=16
IPADDR=192.168.2.15
NETMASK=255.255.255.0
GATEWAY=192.168.2.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
 

[root@mydhcpgw /]# cat /etc/resolv.conf
nameserver 8.8.8.8
 

确保能ping 通外网

[root@mydhcpgw /]# ping www.baidu.com
PING www.a.shifen.com (119.75.217.56) 56(84) bytes of data.
64 bytes from 119.75.217.56: icmp_seq=1 ttl=54 time=2.01 ms
64 bytes from 119.75.217.56: icmp_seq=2 ttl=54 time=2.03 ms
 

2.安装DHCP服务:

#yum install dhcp -y

3.修改主配置文件

[root@mydhcpgw /]# vi /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#
ddns-update-style  none;
ignore  client-updates;
default-lease-time   3600;
max-lease-time   7200;
option routers 172.16.10.1;
option domain-name “mydhcpgw.com”;
option domain-name-servers  8.8.8.8;
subnet  172.16.10.0  netmask  255.255.255.0 {
range  172.16.10.100  172.16.10.150;
host  test1 {
hardware   ethernet  00:14:D5:90:43:17;
fixed-address  172.16.10.108;
}
}

4.启动服务:

#service dhcpd start

#/etc/rc.d/init.d/dhcpd reload

开机自启:

#chkconfig dhcpd on

#chkconfig --level 3 dhcpd .

#用windows xp客户机测试发现 能dhcp获得到ip地址,但是获得不到正确的dns ,连接不到外网;

解决: