CentOS項目執行個體之二--DHCP配置

來源:互聯網
上載者:User

標籤:dhcp 位址集區 日誌查看

1. ZZSRV1上的DHCP配置1.1. 安裝
# mkdir /mnt/cdrom/# mount /dev/cdrom  /mnt/cdrom# cd /mnt/cdrom/Packages/# ls dhcp*dhcp-4.2.5-27.el7.centos.x86_64.rpm  dhcp-common-4.2.5-27.el7.centos.x86_64.rpm  dhcp-libs-4.2.5-27.el7.centos.x86_64.rpm# rpm -Uvh dhcp-4.2.5-27.el7.centos.x86_64.rpmPreparing...                          ################################# [100%]Updating / installing...   1:dhcp-12:4.2.5-27.el7.centos      ################################# [100%]
1.2. 配置


# rpm -qc dhcp/etc/dhcp/dhcpd.conf/etc/dhcp/dhcpd6.conf/etc/openldap/schema/dhcp.schema/etc/sysconfig/dhcpd/var/lib/dhcpd/dhcpd.leases/var/lib/dhcpd/dhcpd6.leases# cd /etc/dhcp/# cp dhcpd.conf dhcpd.conf.origin# cat /etc/dhcp/dhcpd.conf## DHCP Server Configuration file.#   see /usr/share/doc/dhcp*/dhcpd.conf.example#   see dhcpd.conf(5) man page#    查看樣本檔案 # vi /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example

VLAN1的地址租約是3天,VLAN2的地址租約是8天

[[email protected] dhcp]# echo  3*24*60*60 | bc259200[[email protected] dhcp]# echo  8*24*60*60 | bc691200



背景知識:

default-lease-time time;

Time should be the length in seconds that will be assigned to a lease if the client requesting the lease does not ask for a  specific  expiration time.  This is used for both DHCPv4 and DHCPv6 leases (it is also known as the "valid lifetime" in DHCPv6).  The default is 43200 seconds.


max-lease-time time;

Time  should  be  the  maximum length in seconds that will be assigned to a lease.  If not defined, the default maximum lease time is 86400.  The only exception to this is that Dynamic BOOTP lease lengths, which are not specified by the client, are not limited by this maximum.


# vi /etc/dhcp/dhcpd.conf

option domain-name "bigcloud.local";

option domain-name-servers 192.168.188.11, 192.168.188.12;

default-lease-time 691200;

max-lease-time 691200;


subnet 192.168.188.0 netmask 255.255.255.0 {

  range 192.168.188.100 192.168.188.159;

  range 192.168.188.170 192.168.188.253;

  default-lease-time 259200;

  max-lease-time 259200;

  option routers 192.168.188.2;

}


subnet 192.168.189.0 netmask 255.255.255.0 {

  range 192.168.189.100 192.168.189.253;

  option routers 192.168.189.2;

}


host printer1 {

  hardware ethernet 00:12:34:56:78:90;

  fixed-address 192.168.188.111;

}


啟動服務

# service dhcpd start

Redirecting to /bin/systemctl start  dhcpd.service


查看日誌

Internet Systems Consortium DHCP Server 4.2.5

Copyright 2004-2013 Internet Systems Consortium.

All rights reserved.

For info, please visit https://www.isc.org/software/dhcp/

Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file

Wrote 0 deleted host decls to leases file.

Wrote 0 new dynamic host decls to leases file.

Wrote 0 leases to leases file.

Listening on LPF/eno16777728/00:0c:29:a4:2e:39/192.168.188.0/24

Sending on   LPF/eno16777728/00:0c:29:a4:2e:39/192.168.188.0/24

Sending on   Socket/fallback/fallback-net



配置DHCPD為自動 啟動, 這在CentOS 7上的新的變化 了

# chkconfig dhcpd onNote: Forwarding request to ‘systemctl enable dhcpd.service‘.ln -s ‘/usr/lib/systemd/system/dhcpd.service‘ ‘/etc/systemd/system/multi-user.target.wants/dhcpd.service‘# systemctl enable dhcpd# systemctl is-enabled dhcpdenabled


1.3. 測試

在一台Windows客戶機上進行測試

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/4B/03/wKiom1QntsnigOgPAAK5kVLLyAs402.jpg" title="無標題.png" alt="wKiom1QntsnigOgPAAK5kVLLyAs402.jpg" />


當客戶機租用IP地址時,會在日誌中看到

DHCPINFORM from 192.168.188.100 via eno16777728: not authoritative for subnet 192.168.188.0

DHCPREQUEST for 192.168.188.100 from 00:0c:29:b3:a2:60 (TOMSRV1) via eno16777728

DHCPACK on 192.168.188.100 to 00:0c:29:b3:a2:60 (TOMSRV1) via eno16777728

DHCPREQUEST for 192.168.188.100 from 00:0c:29:b3:a2:60 (TOMSRV1) via eno16777728

DHCPACK on 192.168.188.100 to 00:0c:29:b3:a2:60 (TOMSRV1) via eno16777728

DHCPREQUEST for 192.168.188.100 from 00:0c:29:b3:a2:60 (TOMSRV1) via eno16777728

DHCPACK on 192.168.188.100 to 00:0c:29:b3:a2:60 (TOMSRV1) via eno16777728


# tail /var/lib/dhcpd/dhcpd.leases


本文出自 “劉瓊@天道酬勤” 部落格,請務必保留此出處http://lqiong.blog.51cto.com/8170814/1559058

CentOS項目執行個體之二--DHCP配置

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.