Linux dhcp服务

  1. yum install dhcp #安装
    systemctl enable dhcp #自启动
    systemctl start dhcp #启动

2、防火墙和selinux设置

firewall-cmd --permanent --add-service=dhcp
firewall-cmd --reload

semanage port -a -t dhcp_port_t -p tcp 67

确认dhcp是否加入添加进去:
semanage port -l | grep dhcp

3、配置DHCP

查看 /usr/share/doc/dhcp*/dhcpd.conf.example

vi /etc/dhcp/dhcpd.conf

subnet 192.168.9.0  netmask 255.255.255.0 {
  range 192.168.9.100  192.168.9.120;
  option domain-name-servers ns.rhel.com; #域服务器
  option domain-name "rhel.com"; # 域
  option routers 192.168.9.1; #网关
  option broadcast-address 192.168.9.255; #广播地址
  default-lease-time 600; #到期提醒
  max-lease-time 7200; #租期
}

  1. 其他机器192.168.9.3上,测试自动获取iP

nmcli connection modify ens33 ipv4.method auto/manual # 设置自动获取/手动启动

nmcli connection down ens33

nmcli connection up ens33

  1. mac地址绑定固定ip
    vi /etc/dhcp/dhcpd.conf,添加如下格式配置:
    host mycms5 {
    hardware ethernet 00:0C:29:EB:BE:10;
    fixed-address 192.168.9.3;
    }
    host centos7{
    hardware ethernet 00:0C:29:64:0A:7B;
    fixed-address 192.168.9.3;
    }

然后,重启dhcpd服务,即可。

你可能感兴趣的:(Linux dhcp服务)