例如 AppSrv 给 InsideCli 分配地址 经过路由器服务端 RouterSrv
AppSrv 也就是 dhcp服务器端
1. yum源 安装dhcp
yum -y install dhcp
2.将dhcp配置文件的模板文件 复制移动到 安装的dhcp配置文件中(安装的dhcp文件在 /etc/dhcp中)
cp -p /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf 3. vi /etc/dhcp/dhcpd.conf
MAC地址就是
4.重启dhcp
systemctl restart dhcpd
5. 设置dhcp 开机自启,防止下次开机 还要手动重启dhcp
systemctl enable dhcpd
RouterSrv (充当路由器的服务端)
1.yum源安装dhcrelay
yum -y install dhcp-*
2.配置dhcrelay文件
vi /usr/lib/systemd/system/dhcrelay.service
3. dhcrelay 192.168.100.100
4.重启 dhcrelay
systemctl restart dhcrelay
5. 设置开机自启 dhcrelay
systemctl enable dhcrelay
InsideCli 接收dhcp的客户端
查看是否获取到了对应的ip dns 网关
1. systemctl restart network
2. ip addr | grep inet && ip addr | grep route
AppSrv 也就是 dhcp服务器端
修改日志文件
vi /etc/rsyslog.conf (增加如下内容, local1 对应上面dhcpd.conf 中的 log-facility local1)
创建 /var/log/dhcp.log
重启 日志
systemctl restart rsyslog