(13) DHCP service

1. DHCP principle:
      The server installs the DHCP service, and the ip acquisition method of the client host is dhcp, that is, dynamic acquisition; the
      client host asks for a dynamic IP address through the broadcast bit (for example: 172.25.254.255), and the server identifies the mac address of the client host.
   The client host that sends out the broadcast and gives the dynamic IP address
 2. Install dhcp on the server

    1. Configure the server static ip nm-connection-editor


    2. Modify the configuration file /etc/yum.repos.d/rhel_dvd.repo


        Change the yum source to http://172.25.254.148/rhel7.2
    Note: The yum source is shared and can be accessed through http

    3. Install dhcp yum install dhcp -y


    Note: If you don't know the dhcp package, use yum search dhcp to find the package


    4. Query the dhcp configuration file rpm -qc dhcp

Modify the dhcp configuration file /etc/dhcp/dhcpd.conf

Note: The configuration file is empty, you need to copy the template
      cp /usr/share/doc/dhcp*/dhcpd.conf /etc/dhcp/dhcpd.conf


    5. Modify vim /etc/dhcp/dhcpd.conf
      , line 7, set the domain name "westos.com" ,       line
      8, set DNS 172.25.254.250       ,       line
      10 Line 22 log level       line 30 Modify the subnet segment 172.25.254.0 Subnet mask 255.255.255.0            Set the IP address pool (range) 172.25.254.221 172.25.254.231





           set gateway 172.25.254.250


      Delete the content after line 34
    6. Restart the dhcp service systemctl restart dhcpd
  2. The client
    checks the client's ip acquisition method

      /etc/sysconfig/network-scripets/ifcfg-eth0


    Restart the network
      systemctl restart network
    to view the client ip ifconfig
  3. View the dhcp information on the server

    cat  /var/lib/dhcpd/dhcpd.leases


3. Configure DHCP for virtual machine startup
  1. Install pxelinux.0 and
    find the pxelinux.0 software package

    yum whatprovides */pxelinux.0


    Note: The pxelinux.0 package requires tftp sharing, and tftp needs to be installed.
    yum install syslinux-4.05-8.el7.x86_64 tftp-server -y
  2. Modify the configuration file

    vim  /etc/xinetd.d/tftp


    systemctl restart xinetd.service to
    see if the modification is successful
    chkconfig --list

    View the interfaces enabled by xinetd


    netstat -antlupe | grep xinetd
  3. Find the configuration file of
    tftp rpm -ql tftp-server
    Put the pxelinux.0 package in the directory of the configuration file

    cp /usr/share/syslinux/pxelinux.0 / var / lib / tftpboot


    Put all the files in the isolinux directory in the image in the directory of the configuration file

    scp -r /var/www/html/rhel7.2/isolinux/* [email protected]:/var/lib/tftpboot


  4. Query the pxelinux.0 manual
    rpm -qd syslinux
    /usr/share/doc/syslinux-4.05/pxelinux.txt
  5. Create a directory according to the manual
    : mkdir pxelinux.cfg/default
    Copy the file: cp isolinux.cfg pxelinux.cfg/ default
    Note: pxelinux.cfg/default is the file read by pxelinux.0,
    modify the dhcp configuration file
    vim /etc/dhcp/dhcpd.conf
     30 subnet 172.25.254.0 netmask 255.255.255.0 {
     31 range 172.25. 254.201 172.25.254.221;
     32 option routers 172.25.254.250;
     33 next-server 172.25.254.108;
     34 filename "pxelinux.0";
     35 }
     Restart the dhcp service, set firewalld
     systemctl restart dhcpd
     systemctl stop firewalld
     systemctl disable firewalld
   6. The virtual machine starts, boot selects the network card to start

    

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325447941&siteId=291194637