角色 ip地址 网关
dhcp服务器 192.168.8.81 192.168.8.1
客户机1 动态获取 192.168.8.81
客户机2 192.168.8.99 192.168.8.81
a. 安装软件:
yum -y install dhcp
b. 更改配置文件:vim /etc/dhcp/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.8.0 netmask 255.255.255.0 {
range 192.168.8.90 192.168.8.100;
option routers 192.168.8.1;
}
host printer {
hardware ethernet 00:0c:29:48:c5:a2;
fixed-address 192.168.8.99;
}
c. 启动服务:
systemctl start dhcpd
a. 修改网卡配置文件:vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
DEVICE=eth0
ONBOOT=yes
GATEWAY=192.168.8.81 #网关一定要设置成dhcp服务器的ip地址
NETMASK=255.255.255.0
DNS1=8.8.8.8
DNS2=114.114.114.114
b. 重启网络服务:
systemctl restart network
a. 客户机1:
ip a
b. 客户机2:
ip a
原文地址:http://blog.51cto.com/12173069/2069651
时间: 2024-10-14 21:08:08