In DHCP configuration, use of dhcpd

Source: Internet
Author: User

In the course of learning DHCP, we will certainly be exposed to configuration-related content. You will also learn content related to Linux. Many friends also found that dhcpd applications are involved in Linux DHCP configuration. Today, we mainly talk about the use of DHCP and dhcpd packages in Linux. So the test environment: RH linux 9.0 uses the common dhcpd package in linux. The latest version of dhcp3.0.5: download.

1. install the software: Install the/tmp directory first.

 
 
  1. # Cd/tmp
  2. # Gunzip dhcp-3.0.5.tar.gz
  3. # Tar xvf after the dhcp-3.0.5.tar is unlocked, you will see a new sub-directory dhcp-3.0.5 under the Directory
  4. # Cd dhcp-3.0.5 // enter this subdirectory
  5. # Configure
  6. # Make
  7. # Make install dhcp

2. Configuration

 
 
  1. The most important configuration work of the dhcp service is to configure/etc/dhcpd. conf and paste the configuration of the local machine.
  2. /Etc/dhcpd. conf:
  3. Default-lease-time 1296000;
  4. # Maximum IP address expiration time
  5. Max-lease-time 4000000;
  6. Option subnet-mask limit 255.0;
  7. # Subnet Mask
  8. Option broadcast-address 192.168.0.255;
  9. # Broadcast address of the Network
  10. Option routers 192.168.0.254;
  11. # Gateway address
  12. Option domain-name-servers 211.151.48.59, 211.151.48.47;
  13. # Domain name resolution address
  14. Ddns-update-style ad-hoc;
  15. Subnet 192.168.0.0 netmask 255.255.255.0 {
  16. # Define the IP address pool content
  17. Range 192.168.0.100 192.168.0.240;
  18. # The IP address range is 100-240, with a total of 140 IP addresses.
  19. }
  20. # You can also specify an IP address based on the MAC address as follows:
  21. # Host Jephe {hardware ethernet 00: a0: c9: a6: 96: 33; fixed-address 192.168.1.12 ;}

The dhcpd. conf file has been configured.

3. Start the service

 
 
  1. #dhcpd 

That is, it can be started in command line mode.

Add the command to the startup.

Edit or create the/etc/rc. d/init. d/dhcpd file and write the following content:

 
 
  1. #vi /etc/init.d/dhcpd  
  2. . /etc/rc.d/init.d/functions  
  3. . /etc/sysconfig/network  
  4.  
  5. # Check that networking is up.  
  6. [ ${NETWORKING} = "no" ] && exit 0  
  7. [ -f /usr/sbin/dhcpd ] || exit 0  
  8. [ -f /etc/dhcpd.conf ] || exit 0  
  9.  
  10. RETVAL=0 
  11. # See how we were called.  
  12. case "$1" in  
  13. start)  
  14.  
  15. # Start daemons.  
  16. echo -n "Starting dhcpd: "  
  17. daemon /usr/sbin/dhcpd eth1  
  18. RETVAL=$?  
  19. echo  
  20. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd  
  21. ;;  
  22.  
  23. stop)  
  24. # Stop daemons.  
  25. echo -n "Shutting down dhcpd: "  
  26. killproc dhcpd  
  27. RETVAL=$?  
  28. echo  
  29. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dhcpd  
  30. ;;  
  31.  
  32. restart|reload)  
  33. $0 stop  
  34. $0 start  
  35. RETVAL=$?  
  36. ;;  
  37.  
  38. status)  
  39. status dhcpd  
  40. RETVAL=$?  
  41. ;;  
  42.  
  43. *)  
  44. echo "Usage: dhcpd {start|stop|restart|status}"  
  45. exit 1  
  46. esac  
  47. exit $RETVAL 

The daemon/usr/sbin/dhcpd eth0 clause specifies that the machine in the IP segment of the NIC needs to be parsed.

If the second Nic is set to: eth1

Start and Stop using service commands

 
 
  1. #service dhcpd start|stop|restart 

If no error is returned, the configuration file is correct.

Add to the startup service:

 
 
  1. # Chkconfig -- add dhcpd
  2. # Chkconfig -- level 2345 dhcpd on
  3. # Chkconfig -- list dhcpd
  4. # Dhcpd 0: Disable 1: Disable 2: Enable 3: Enable 4: Enable 5: Enable 6: Disable

The configuration is complete!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.