RedHat8配置DHCP
RedHat 8配置DHCP
环境:redhat8-DHCP(服务器)、windows server2008(客户端)
- redhat配置静态IP地址:
vim /etc/sysconfig/network-scripts/ifcfg-ens160 TYPE="Ethernet" PROXY_METHOD="none" BROWSER_ONLY="no" ONBOOT="YES" BOOTPROTO="none" IPADDR=192.168.0.1 METMASK=255.255.255.0 DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="ens160" UUID="dbba5a7e-bd62-438b-a188-68cb83d46b95" DEVICE="ens160" ONBOOT="yes" IPV6_PRIVACY="no"
[root@localhost ~]# systemctl restart NetworkManager [root@localhost ~]# ifconfig ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.0.1 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::54eb:b207:4fc8:7d6c prefixlen 64 scopeid 0x20<link> ether 00:0c:29:cb:6e:4b txqueuelen 1000 (Ethernet) RX packets 687 bytes 53516 (52.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 192 bytes 20560 (20.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 - 把镜像接入光驱,用于安装dhcpd安装包
- df查看光驱挂在位置
[root@localhost ~]# df 文件系统 1K-块 已用 可用 已用% 挂载点 devtmpfs 892204 0 892204 0% /dev tmpfs 921340 0 921340 0% /dev/shm tmpfs 921340 9908 911432 2% /run tmpfs 921340 0 921340 0% /sys/fs/cgroup /dev/mapper/rhel-root 17811456 4647752 13163704 27% / /dev/nvme0n1p1 1038336 234392 803944 23% /boot tmpfs 184268 1168 183100 1% /run/user/42 tmpfs 184268 4644 179624 3% /run/user/0 /dev/sr0 8238560 8238560 0 100% /run/media/root/RHEL-8-2-0-BaseOS-x86_64
- 查找dhcp安装包
[root@localhost ~]# cd /run/media/root/RHEL-8-2-0-BaseOS-x86_64/BaseOS/Packages/ [root@localhost Packages]# ls dhcp-* dhcp-client-4.3.6-40.el8.x86_64.rpm dhcp-libs-4.3.6-40.el8.x86_64.rpm dhcp-common-4.3.6-40.el8.noarch.rpm dhcp-relay-4.3.6-40.el8.x86_64.rpm dhcp-libs-4.3.6-40.el8.i686.rpm dhcp-server-4.3.6-40.el8.x86_64.rpm
- 安装dhcp
[root@localhost Packages]# rpm -ivh dhcp-server-4.3.6-40.el8.x86_64.rpm 警告:dhcp-server-4.3.6-40.el8.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY Verifying... ################################# [100%] 准备中... ################################# [100%] 正在升级/安装... 1:dhcp-server-12:4.3.6-40.el8 ################################# [100%]
- 配置dhcp文件
[root@localhost ~]# cd /etc/dhcp/ [root@localhost dhcp]# ls dhclient.conf dhclient.d dhcpd6.conf dhcpd.conf [root@localhost dhcp]# cp /usr/share/doc/dhcp-server/dhcpd.conf.example dhcpd.conf cp:是否覆盖'dhcpd.conf'? yes [root@localhost dhcp]# vim dhcpd.conf
dhcpd.conf # # Sample configuration file for ISC dhcpd # # option definitions common to all supported networks... option domain-name "example.org"; option domain-name-servers 114.114.114.114; default-lease-time 600; max-lease-time 7200; # Use this to enble / disable dynamic dns updates globally. #ddns-update-style none; # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative; # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7; # This is a very basic subnet declaration. subnet 192.168.0.0 netmask 255.255.255.0 { ##设置网段、掩码 range dynamic-bootp 192.168.0.100 192.168.0.200; ##分配IP地址 option routers 192.168.0.1; ##网关 } - 重启服务
[root@localhost dhcp]# systemctl restart dhcpd
- 测试dhcp服务器
在windows server 2008上查看是否生效

在Redhat8中查看IP分配情况


浙公网安备 33010602011771号