CentOS7.3搭建dhcp服务器
来源:互联网 发布:回收站数据恢复 免费 编辑:程序博客网 时间:2024/05/16 04:50
一、实验环境:
VMware Workstation 12, CentOS 7.3 x64系统, CentOS 7.3 x64系统安装光盘
二、实验过程:
1.配置虚拟机软件的“虚拟网络编辑器”,将vmnet1网段修改如下图
2.修改CentOS7.3系统的仅主机模式的网卡,如下图
3.配置本地yum源
[root@centos7 ~]#mkdir /etc/yum.repos.d/backup[root@centos7 ~]#mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup[root@centos7 ~]#mount /dev/sr0 /mnt/cdrom[root@centos7 ~]# vim /etc/yum.repos.d/basecd.repo[root@centos7 ~]# cat /etc/yum.repos.d/basecd.repo [basecd]name=basecdbaseurl=file:///mnt/cdromgpgcheck=0
4.将仅主机模式的网卡设定成静态IP
[root@centos7 ~]# nmcli con mod ens33 ipv4.method manual ipv4.address 192.168.21.7/24[root@centos7 ~]# nmcli con up ens33Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
5.安装dhcp服务,并设置dhcp.conf
[root@centos7 ~]# yum -y install dhcp[root@centos7 ~]# cat /etc/dhcp/dhcpd.conf## DHCP Server Configuration file.# see /usr/share/doc/dhcp*/dhcpd.conf.example# see dhcpd.conf(5) man page#[root@centos7 ~]# cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.confcp: overwrite ‘/etc/dhcp/dhcpd.conf’? y[root@centos7 ~]# vim /etc/dhcp/dhcp.conf 需要修改:7行:option domain-name "example.org" 改为 option domain-name "hengxia.top" # dhcp的主机名8行:option domain-name-servers ns1.example.org, ns2.example.org; 改为option domain-name-servers 114.114.114.114; # DNS服务器新增:27行: subnet 192.168.21.0 netmask 255.255.255.0 { range 192.168.21.60 192.168.21.80; # 分配地址范围 option routers 192.168.21.1; # 增加默认网关 option domain-name-servers 114.114.114.114; # 默认DNS服务器 }[root@centos7 ~]# systemctl start dhcpd # 启动dhcpd服务
6.在测试centos6.9 64位系统上修改网卡为仅主机模式,修改仅主机模式的卡为dhcp获取。测试可以获取到。
[root@centos7 ~] cd /var/lib/dhcpd/ # 在CentOS7.3 DHCP 服务器上可以看到CentOS6.9 获取地址的信息[root@centos7 ~]# cat dhcpd.leases# The format of this file is documented in the dhcpd.leases(5) manual page.# This lease file was written by isc-dhcp-4.2.5server-duid "\000\001\000\001!\006%6\000\014)\005#\025";lease 192.168.21.60 { starts 6 2017/07/22 15:19:37; ends 6 2017/07/22 15:29:37; cltt 6 2017/07/22 15:19:37; binding state active; next binding state free; rewind binding state free; hardware ethernet 00:0c:29:01:71:22; client-hostname "centos6.xh.com";}[root@centos6 ~] cd /var/lib/dhclient # 在获取IP主机上查看获取IP信息[root@centos6 dhclient]# ls -lt | head -n 2 # 获取最新的记录total 104-rw-r--r--. 1 root root 2496 Jul 22 10:36 dhclient-c9090166-5360-40ea-968f-65fcb08a6a8e-eth0.lease[root@centos6 dhclient]# cat dhclient-c9090166-5360-40ea-968f-65fcb08a6a8e-eth0.leaselease { interface "eth0"; fixed-address 192.168.21.60; option subnet-mask 255.255.255.0; option routers 192.168.21.1; option dhcp-lease-time 600; option dhcp-message-type 5; option domain-name-servers 114.114.114.114; option dhcp-server-identifier 192.168.21.7; option domain-name "centos7.com"; renew 6 2017/07/22 02:36:08; rebind 6 2017/07/22 02:40:20; expire 6 2017/07/22 02:41:35;}lease { interface "eth0"; fixed-address 192.168.21.60; option subnet-mask 255.255.255.0; option routers 192.168.21.1; option dhcp-lease-time 600; option dhcp-message-type 5; option domain-name-servers 114.114.114.114; option dhcp-server-identifier 192.168.21.7; option domain-name "centos7.com"; renew 6 2017/07/22 02:40:49; UTC时间 date -u转换 rebind 6 2017/07/22 02:44:59; expire 6 2017/07/22 02:46:14;}
阅读全文
0 0
- CentOS7.3搭建dhcp服务器
- centos7 搭建DHCP服务器
- centos7搭建DHCP简要服务器
- centos7搭建clonezilla PXE启动(不需要配置dhcp服务器)
- DHCP服务器的搭建
- 搭建DHCP服务器
- linux 搭建DHCP 服务器
- DHCP服务器搭建
- DHCP服务器的搭建
- DHCP服务器的搭建
- ubuntu搭建dhcp服务器
- #9.DHCP服务器搭建
- Linux dhcp服务器搭建
- centos dhcp服务器搭建
- Linux-搭建DHCP服务器
- 搭建DHCP服务器
- [App] DHCP 服务器搭建
- dhcp服务器搭建
- OCR / Vote disk Maintenance Operations: (ADD/ REMOVE/REPLACE/MOVE)
- jsp里的参数如何与javabean里的参数对应
- rocketmq
- 第4章 虚拟机性能监控与故障处理工具
- JDBC
- CentOS7.3搭建dhcp服务器
- python的I/O操作
- 匿名内部类的创建原理
- Android_浅谈
- 【Web】vue2.0音乐APP实战中的知识点总结(二)
- linux
- unity_每日随笔_MyButton
- Crash 现场分析
- mybatis3中@SelectProvider的使用技巧