搭建dhcp服务器
搭建dhcp服务器使其能够给192.168.27.0网段和192.168.136.0网段的主机分配ip地址,dhcp服务器可以给该网段的主机分配固定ip地址为192.168.27.8和192.168.136.168。
首先安装dhcp服务
[root@localhost ~]# mount /dev/sr0 /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@localhost ~]# yum install dhcp-server -y
然后编写配置文件
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
option domain-name "example.org";
option domain-name-servers 192.168.136.2;
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
ignore client-updates;
subnet 192.168.136.0 netmask 255.255.255.0{
range 192.168.136.100 192.168.136.200;
}
subnet 192.168.27.0 netmask 255.255.255.0{
range 192.168.27.10 192.168.27.20;
}
host nat{
hardware ethernet 00:0c:29:77:f8:75;
fixed-address 192.168.136.168;
}
host only{
hardware ethernet 00:0c:29:77:f8:7f;
fixed-address 192.168.27.8;
}
然后关闭防火墙,重启服务
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl restart dhcpd
最后到客户端去获取地址
[root@localhost ~]# dhclient
如果获取不到要up一下连接,就能成功获取到地址