DHCP Service Construction

Source: Internet
Author: User
Tags domain name server

DHCP Service Construction
DHCP Service Construction

  • First, we need to install the DHCP software package. We use the rpm package to install it with yum.
[root@localhost ~]# yum install -y dhcp.x86_64
  • You need to modify the configuration file:/etc/dhcpd. conf. Before modification, we need a template file cp
[Root @ localhost ~] # Cp/usr/share/doc/dhcp-4.1.1/dhcpd. conf. sample/etc/dhcp/dhcpd. conf [root @ localhost ~] # Vim/etc/dhcp/dhcpd. conf subnet 192.168.4.0 netmask 255.255.255.0 {range 192.168.4.10 192.168.4.200; option domain-name-servers 8.8.8.8; option domain-name "internal.example.org"; option routers 192.168.4.1; option broadcast-address 192.168.4.255; default-lease-time 600; max-lease-time 7200;}> Subnet: CIDR Block declaration acts on the entire Subnet segment> range: set the starting IP address of the IP address pool for allocation> option domain-name-servers: Set the specified domain name Server> option routers : Set the gateway address> option broadcast-address: Set the broadcast address> option subnet-mask: Set the subnet mask of the client> Host: reserve the Host and act on a single Host, (usually prevent the subnet Declaration of the network segment)> default-lease-time: Set the default lease> max-lease-time: Maximum lease time> hardware ethernet parameter: specify the MAC address> fixed-address parameter of the corresponding host: Specify the IP address reserved for the host-Description: If the dhcp server wants to configure IP addresses of different network segments, you must have a declaration of the same network segment as the local IP address.
  • Start the DHCP service and set it to the auto-Starting Status.
[root@localhost ~]# service dhcpd startStarting dhcpd:                                            [  OK  ][root@localhost ~]# chkconfig dhcpd on[root@localhost ~]# chkconfig --list dhcpddhcpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
  • Check whether the dhcp service is started normally and listening. The default dhcp Service port is UDP67.
[root@localhost ~]# netstat -natpu | grep 67udp        0      0 0.0.0.0:67                  0.0.0.0:*                               5548/dhcpd   
  • The client uses dhcp to release and obtain the assigned ip address of the dhcp server.
    Obtained: Dhclient-d eth1
[root@localhost ~]# dhclient -d eth1Internet Systems Consortium DHCP Client 4.1.1-P1Copyright 2004-2010 Internet Systems Consortium.All rights reserved.For info, please visit https://www.isc.org/software/dhcp/Listening on LPF/eth1/00:0c:29:33:4a:0cSending on   LPF/eth1/00:0c:29:33:4a:0cSending on   Socket/fallbackDHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 8 (xid=0x68888b56)DHCPOFFER from 192.168.4.115DHCPREQUEST on eth1 to 255.255.255.255 port 67 (xid=0x68888b56)DHCPACK from 192.168.4.115 (xid=0x68888b56)

Release: dhclient-r eth1

[root@localhost ~]# dhclient -r eth1
  • Main files of the dhcp Software Package
    -Main configuration file:/etc/dhcpd. conf
[root@bkjia ~]# ls -ltr /etc/dhcp/dhcpd.conf -rw-r--r--. 1 root root 3260 Apr 12 15:10 /etc/dhcp/dhcpd.conf

-Execution program:/usr/sbin/dhcpd,/usr/sbin/dhcrelay

[root@bkjia ~]# ls -ltr /usr/sbin/dhcpd -rwxr-xr-x. 1 root root 825904 Sep 25  2012 /usr/sbin/dhcpd[root@bkjia ~]# ls -ltr /usr/sbin/dhcrelay -rwxr-xr-x. 1 root root 465680 Sep 25  2012 /usr/sbin/dhcrelay

-Service Script:/etc/init. d/dhcpd,/etc/init. d/dhcrelay

[root@bkjia ~]# ls -ltr /etc/init.d/dhcpd-rwxr-xr-x. 1 root root 3118 Sep 25  2012 /etc/init.d/dhcpd[root@bkjia ~]# ls -ltr /etc/init.d/dhcrelay -rwxr-xr-x. 1 root root 2510 Sep 25  2012 /etc/init.d/dhcrelay

-Run the parameter configuration:/etc/sysconfig/dhcpd.

[root@bkjia ~]# ls -ltr /etc/sysconfig/dhcpd-rw-r--r--. 1 root root 39 Sep 25  2012 /etc/sysconfig/dhcpd

-DHCP relay configuration:/etc/sysconfig/dhcrelay

[root@bkjia ~]# ls -ltr /etc/sysconfig/dhcrelay-rw-r--r--. 1 root root 101 Sep 25  2012 /etc/sysconfig/dhcrelay

At this point, we have simply set up the dhcp service. The following small partner can obtain the IP address from the dhcp server, and then we will configure different IP addresses for clients in different network segments.

This article permanently updates the link address:

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.