Bài giảng Quản trị Linux - Chủ đề 10: Dynamic Host Configuration Protocol

pdf 33 trang phuongnguyen 3250
Bạn đang xem 20 trang mẫu của tài liệu "Bài giảng Quản trị Linux - Chủ đề 10: Dynamic Host Configuration Protocol", để tải tài liệu gốc về máy bạn click vào nút DOWNLOAD ở trên

Tài liệu đính kèm:

  • pdfbai_giang_quan_tri_linux_chu_de_10_dynamic_host_configuratio.pdf

Nội dung text: Bài giảng Quản trị Linux - Chủ đề 10: Dynamic Host Configuration Protocol

  1. Đặng Thanh Bình Dynamic Host Configuration Protocol
  2. Contents • Why Use DHCP? • Configuring a DHCP Server • Configuring a DHCP Client
  3. WHY USE DHCP?
  4. Why Use DHCP? • Dynamic Host Configuration Protocol (DHCP) is a network protocol that automatically assigns TCP/IP information to client machines. • Each DHCP client connects to the centrally located DHCP server, which returns that client's network configuration (including the IP address, gateway, and DNS servers).
  5. Why Use DHCP? • DHCP is useful for automatic configuration of client network interfaces. • When configuring the client system, the administrator chooses DHCP instead of specifying an IP address, netmask, gateway, or DNS servers. • The client retrieves this information from the DHCP server.
  6. Why Use DHCP? • DHCP is also useful if an administrator wants to change the IP addresses of a large number of systems. • Instead of reconfiguring all the systems, he can just edit one DHCP configuration file on the server for the new set of IP addresses. – If the DNS servers for an organization changes, the changes are made on the DHCP server, not on the DHCP clients.
  7. Why Use DHCP? • If an organization has a functional DHCP server properly connected to a network, laptops and other mobile computer users can move these devices from office to office.
  8. CONFIGURING A DHCP SERVER
  9. Configuring a DHCP Server • To configure a DHCP server, you must create the dhcpd.conf configuration file in the /etc/dhcp directory. • A sample file can be found at /usr/share/doc/dhcp- /dhcpd.conf.sample • DHCP also uses the file /var/lib/dhcpd/dhcpd.leases to store the client lease database.
  10. Configuration File • The first step in configuring a DHCP server is to create the configuration file that stores the network information for the clients. • Use this file to declare options and global options for client systems. • The configuration file can contain extra tabs or blank lines for easier formatting. Keywords are case-insensitive and lines beginning with a hash mark (#) are considered comments.
  11. DNS update schemes • Two DNS update schemes are currently implemented – the ad-hoc DNS update mode – the interim DHCP-DNS interaction update mode. • You must configure the DNS server for compatibility with these schemes.
  12. DNS update schemes • To use adhoc mode, add the following line to the top of the configuration file • To use the recommended mode, add the following line to the top of the configuration file
  13. Types Of Statements • Two types of statements in the configuration file: – Parameters — State how to perform a task, whether to perform a task, or what network configuration options to send to the client. – Declarations — Describe the topology of the network, describe the clients, provide addresses for the clients, or apply a group of parameters to a group of declarations.
  14. Ex. 1. Subnet Declaration • There are global options for every DHCP client in the subnet and a range declared. Clients are assigned an IP address within the range
  15. Ex. 2. Shared-network Declaration • All subnets that share the same physical network should be declared within a shared-network declaration • Parameters within the shared-network, but outside the enclosed subnet declarations, are considered to be global parameters. • The name of the shared-network must be a descriptive title for the network, such as using the title 'test-lab' to describe all the subnets in a test lab environment.
  16. Ex. 2. Shared-network Declaration
  17. Ex. 3. Group Declaration • The group declaration is used to apply global parameters to a group of declarations. • For example, shared networks, subnets, and hosts can be grouped.
  18. Ex. 3. Group Declaration
  19. Ex. 4. Range Parameter • To configure a DHCP server that leases a dynamic IP address to a system within a subnet, modify Example 4, “Range Parameter” with your values. • It declares a default lease time, maximum lease time, and network configuration values for the clients. • This example assigns IP addresses in the range 192.168.1.10 and 192.168.1.100 to client systems.
  20. Ex. 4. Range Parameter
  21. Ex. 5. Static IP Address using DHCP • To assign an IP address to a client based on the MAC address of the network interface card, use the hardware ethernet parameter within a host declaration. • As demonstrated in Example 5, “Static IP Address using DHCP”, the host apex declaration specifies that the NIC with the MAC address 00:A0:78:8E:9E:AA always receives the IP address 192.168.1.4. • Note that the optional parameter host-name can also be used to assign a host name to the client.
  22. Ex. 5. Static IP Address using DHCP
  23. Lease Database • On the DHCP server, the file /var/lib/dhcpd/dhcpd.leases stores the DHCP client lease database • All times in the lease database are in Coordinated Universal Time (UTC), not local time. • The lease database is recreated from time to time so that it is not too large. – First, all known leases are saved in a temporary lease database. – The dhcpd.leases file is renamed dhcpd.leases~ and the temporary lease database is written to dhcpd.leases.
  24. Starting and Stopping the Server • To start the DHCP service, use the command /sbin/service dhcpd start. • To stop the DHCP server, use the command /sbin/service dhcpd stop. • By default, the DHCP service does not start at boot time. To configure the daemon to start automatically at boot time, use chkconfig
  25. Starting and Stopping the Server • If more than one network interface is attached to the system, but the DHCP server should only be started on one of the interfaces, configure the DHCP server to start only on that device. • In /etc/sysconfig/dhcpd, add the name of the interface to the list of DHCPDARGS:
  26. DHCP Relay Agent • The DHCP Relay Agent (dhcrelay) allows for the relay of DHCP and BOOTP requests from a subnet with no DHCP server on it to one or more DHCP servers on other subnets. • When a DHCP client requests information, the DHCP Relay Agent forwards the request to the list of DHCP servers specified when the DHCP Relay Agent is started.
  27. DHCP Relay Agent • When a DHCP server returns a reply, the reply is broadcast or unicast on the network that sent the original request. • The DHCP Relay Agent listens for DHCP requests on all interfaces unless the interfaces are specified in /etc/sysconfig/dhcrelay with the INTERFACES directive. • To start the DHCP Relay Agent, use the command service dhcrelay start.
  28. CONFIGURING A DHCP CLIENT
  29. Configuring DHCP Clients • The first step is to make sure the kernel recognizes the network interface card. • To configure a DHCP client manually – Modify the /etc/sysconfig/network file to enable networking – Modify the configuration file for each network device in the /etc/sysconfig/network-scripts directory. • In this directory, each device should have a configuration file named ifcfg-eth0, where eth0 is the network device name.
  30. /etc/sysconfig/network file • The /etc/sysconfig/network file should contain the following line: • The NETWORKING variable must be set to yes if you want networking to start at boot time.
  31. /etc/sysconfig/network-scripts/ifcfg-eth0 • The /etc/sysconfig/network-scripts/ifcfg-eth0 file should contain the following lines: • A configuration file is needed for each device to be configured to use DHCP.
  32. /etc/sysconfig/network-scripts/ifcfg-eth0 • Other options for the network script – DHCP_HOSTNAME — Only use this option if the DHCP server requires the client to specify a hostname before receiving an IP address. (The DHCP server daemon in Red Hat Enterprise Linux does not support this feature.) – PEERDNS= , where is one of the following: • yes — Modify /etc/resolv.conf with information from the server. If using DHCP, then yes is the default. • no — Do not modify /etc/resolv.conf.
  33. /etc/sysconfig/network-scripts/ifcfg-eth0 • Other options for the network script – SRCADDR= , where is the specified source IP address for outgoing packets. – USERCTL= , where is one of the following: • yes — Non-root users are allowed to control this device. • no — Non-root users are not allowed to control this device.