Dhcp安装配置
方法一:
1、Yum –y install dhcp
方法二:
挂载光盘:
Mkdir –p /home/cd
mount /dev/cdrom /home/cd
cd /home/cd/
ls | grep dhcp
rpm –ivh dhcp……….rpm
2、查看默认的配置文件及路径:
Cat /etc/dhcpd.conf
# DHCP Server Configuration file.
#    see /usr/share/doc/dhcp*/dhcpd.conf.sample 
# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
Cp:是否覆盖?/etc/dhcpd.conf?y
# vi /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
shared-network xiaolong {
option domain-name-servers       202.96.134.33,8.8.8.8;
default-lease-time 21600;
max-lease-time 43200;
option time-offset               -18000;
 
subnet 192.168.10.0 netmask 255.255.255.0 {
 
        option routers                  192.168.10.1;
        option subnet-mask              255.255.255.0;
        range dynamic-bootp 192.168.10.30 192.168.10.220;
 
 }
subnet 192.168.20.0 netmask 255.255.255.0 {
 
        option routers                  192.168.20.1;
        option subnet-mask              255.255.255.0;
        range dynamic-bootp 192.168.20.30 192.168.20.220;
 
 
 }
}
 
eth0       Link encap:Ethernet HWaddr 00:0C:29:4E:65:44 
          inet addr:192.168.10.1 Bcast:192.168.3.255 Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
          RX packets:505089 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13462 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:62108907 (59.2 MiB) TX bytes:1827624 (1.7 MiB)
 
eth0:1     Link encap:Ethernet HWaddr 00:0C:29:4E:65:44 
          inet addr:192.168.20.1 Bcast:192.168.3.255 Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 
eth0:2     Link encap:Ethernet HWaddr 00:0C:29:4E:65:44 
          inet addr:192.168.30.1 Bcast:192.168.3.255 Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 
 
 
3、运用在那个网卡/etc/sysconfig/dhcpd配置
# vi /etc/sysconfig/dhcpd
# Command line options here
DHCPDARGS= (”eth0 eth1”)
4、启动服务:
# service dhcpd start
# netstat -anpu | grep dhcpd
udp         0      0 0.0.0.0:67                  0.0.0.0:*                               2934/dhcpd
5、查看地址获取:
# tail -50 /var/lib/dhcpd/dhcpd.leases
6、DHCP中继:
1、开启路由转发:
# vi /etc/sysctl.conf
# Controls IP packet forwarding
net.ipv4.ip_forward = 1
#sysctl –p
2、设置允许DHCP中继数据的接口及DHCP服务器的IP地址:
# vi /etc/sysconfig/dhcrelay
# Command line options here
INTERFACES="eth0 eth1"
DHCPSERVERS="192.168.1.1"
3、启动中继程序:
Service dhcrelay start
Chkconfig –level 35 dhcrelay on