Linux中进行DHCP的配置范例

发布时间:2011-09-22 10:56:13

Linux中进行DHCP的配置

以下红色区域是自己要修改的成自己的DHCP获取的地址范围

[root@OracleOnLinux root]# cp /usr/share/doc/dhcp-3.0pl1/dhcpd.conf.sample /etc/dhcpd.conf
[root@OracleOnLinux root]# vi /etc/dhcpd.conf
      1 ddns-update-style interim;
      2 ignore client-updates;
      3
      4 subnet 192.168.0.0 netmask 255.255.255.0 { ----“注:192.168.0.0是你给DHCP提供地址池的IP,而255.255.255.0是子网掩码”
      5
      6 # --- default gateway
      7         option routers                  192.168.0.254;
      8         option subnet-mask              255.255.255.0;
      9
     10   #     option nis-domain               "mylinux.org"; ----“域名,没有域名的话可以在option nis-domain的前面加#
     11   #      option domain-name              "mylinux.org"; ----“域名,在windows环境下很有用,比如你的客户端是在那一个域,这里就要改成客户端所在的域名。没有域名的话可以在option domain-name的前面加#
     12         option domain-name-servers      192.168.0.154,61.139.2.69; -----192.168.0.15461.139.2.69是你的DHCP客户端获取的DNS
     13
     14         option time-offset              -18000; # Eastern Standard Time
     15 #       option ntp-servers              192.168.1.1;
     16 #       option netbios-name-servers     192.168.1.1;
     17 # --- Selects point-to-point node (default is hybrid). Don't change this unless
     18 # -- you understand Netbios very well
     19 #       option netbios-node-type 2;
     20
     21         range dynamic-bootp 192.168.0.18 192.168.0.100; ---动态地址池,你想给客户端获取的IP
     22         range dynamic-bootp 192.168.0.160 192.168.0.200; ---动态地址池,你想给客户端获取的IP

     23         default-lease-time 21600;
     24         max-lease-time 43200;
     25
     26         # we want the nameserver to appear at a fixed address
     27         host ns1 {
     28                 next-server marvin.redhat.com;
     29                 hardware ethernet 12:34:56:78:AB:CD;
     30                 fixed-address 192.168.0.17;
     31         } --“将192.168.0.17绑定给MAK地址为12:34:56:78:AB:CD的主机”
     32         host db1 {
     33                 hardware ethernet 00:50:56:C0:00:01;
     34                 fixed-address 192.168.0.16;
     35         }
     36
     37
     38
     39 }
"/etc/dhcpd.conf" [已转换] 39L, 1054C 已写入                                          
[root@OracleOnLinux root]# service dhcpd restart
关闭 dhcpd[失败]
启动 dhcpd确定  ]
[root@OracleOnLinux root]#
=========================================================================================
linux客户机配置:
[root@OracleOnLinux dhcp]# cd /etc/sysconfig/network-scripts/
[root@OracleOnLinux network-scripts]# cat ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=dhcp
-------------------------------------
租借:   dhclient eth1
====================================================================================

windows客户机配置

1、设置为自动获取IP
2、手动租借:ipconfig /release      ipconfig /renew  

====================================================================
查看地址的租借情况:

root@OracleOnLinux root]# cd /var/lib/dhcp
[root@OracleOnLinux dhcp]# ls
dhclient.leases  dhcpd.leases  dhcpd.leases~
[root@OracleOnLinux dhcp]# more dhcpd.leases
# All times in this file are in UTC (GMT), not your local timezone.   This is
# not a bug, so please don't ask about it.   There is no portable way to
# store leases in the local timezone, so please don't request this as a
# feature.   If this is inconvenient or confusing to you, we sincerely
# apologize.   Seriously, though - don't ask.
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-V3.0pl1

lease 192.168.0.200 {
  starts 4 2007/04/26 11:46:57;
  ends 4 2007/04/26 17:46:57;
  binding state active;
  next binding state free;
  hardware ethernet 00:0c:29:1d:59:af;
}
[root@OracleOnLinux dhcp]# more dhclient.leases
lease {
  interface "eth1";
  fixed-address 192.168.0.200;
  option subnet-mask 255.255.255.0;
  option time-offset -18000;
  option routers 192.168.0.254;
  option dhcp-lease-time 21600;
  option dhcp-message-type 5;
  option domain-name-servers 192.168.0.154,61.139.2.69;
  option dhcp-server-identifier 192.168.0.154;
  option nis-domain "mylinux.org";
  option domain-name "mylinux.org";
  renew 4 2007/4/26 14:22:04;
  rebind 4 2007/4/26 17:01:57;
  expire 4 2007/4/26 17:46:57;
}

Linux中进行DHCP的配置范例

相关推荐