1. 安装dhcp,yum -y install dhcp
  2. 配置环境:服务端跟客户段网络都要改成仅主机模式,不能自动获取dhcp。
  3. 配置/etc/dhcp/dhcpd.conf,增加以下内容:
  4. shared-network supper {
      subnet 192.168.8.0 netmask 255.255.255.0 {
        range 192.168.8.101 192.168.8.101;
        option routers 192.168.8.254;
        option broadcast-address 192.168.8.1;
        default-lease-time 86400;
        max-lease-time 259200;
      }
      subnet 192.168.9.0 netmask 255.255.255.0 {
        range 192.168.9.101 192.168.9.200;
        option routers 192.168.9.254;
        option broadcast-address 192.168.9.1;
        default-lease-time 86400;
        max-lease-time 259200;
      }
    }

    这样设置了两个地址池。如果只需要一个地址池:

    subnet 192.168.8.0 netmask 255.255.255.0 {
      range 192.168.8.101 192.168.8.101;
      option routers 192.168.8.254;
      option broadcast-address 192.168.8.1;
      default-lease-time 86400;
      max-lease-time 259200;
    }
  5. 重启dhcpd服务,关闭防火墙,然后在客户端进行测试:
  6. dhclient -r ens33 (释放ip)
    dhclient -d ens33 (获取ip)

希望这样的HTML格式对你有帮助。如果还有其他问题,请随时提问。