服務(wù)器系統(tǒng)是centOS6,雙網(wǎng)卡,
內(nèi)網(wǎng)卡:eth1 /IP 172.16.10.1 Bcast:172.16.255.255 Mask:255.255.0.0
外網(wǎng)卡:eth0 /IP 192.168.2.15 Bcast:192.168.255.255 Mask:255.255.0.0
1.先配置好網(wǎng)卡 使之能連通外網(wǎng)
[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 通外網(wǎng)
[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服務(wù):
#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.啟動(dòng)服務(wù):
#service dhcpd start
#/etc/rc.d/init.d/dhcpd reload
開(kāi)機(jī)自啟:
#chkconfig dhcpd on
#chkconfig --level 3 dhcpd .
#用windows xp客戶機(jī)測(cè)試發(fā)現(xiàn) 能dhcp獲得到ip地址,但是獲得不到正確的dns ,連接不到外網(wǎng);
解決: 本文出自:億恩科技【mszdt.com】
服務(wù)器租用/服務(wù)器托管中國(guó)五強(qiáng)!虛擬主機(jī)域名注冊(cè)頂級(jí)提供商!15年品質(zhì)保障!--億恩科技[ENKJ.COM]
|