一、ssh连接Linux
Connection to 192.168 .3.169 closed.
PS C:\ Users\ jeven> ssh root@192.168.3.169
root@192.168.3.169's password:
Last login: Mon Oct 17 01:13:05 2022 from computer-work.dhcp-route
[ root@serer01 ~]
[ root@serer01 ~]
anaconda-ks.cfg
[ root@serer01 ~]
二、检查系统版本
[ root@serer01 ~]
NAME = "CentOS Linux"
VERSION = "7 (Core)"
ID = "centos"
ID_LIKE = "rhel fedora"
VERSION_ID = "7"
PRETTY_NAME = "CentOS Linux 7 (Core)"
ANSI_COLOR = "0;31"
CPE_NAME = "cpe:/o:centos:centos:7"
HOME_URL = "https://www.centos.org/"
BUG_REPORT_URL = "https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT = "CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION = "7"
REDHAT_SUPPORT_PRODUCT = "centos"
REDHAT_SUPPORT_PRODUCT_VERSION = "7"
三、设置yum仓库
1.设置阿里的yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
2.检查yum仓库
[ root@serer01 ~]
base/7/x86_64 CentOS-7 - Base - mirrors.a enabled: 10,072
docker-ce-stable/7/x86_64 Docker CE Stable - x86_64 enabled: 169
extras/7/x86_64 CentOS-7 - Extras - mirrors enabled: 515
updates/7/x86_64 CentOS-7 - Updates - mirror enabled: 4,300
四、安装DHCP服务
1.安装dhcp
[ root@serer01 ~]
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12 :4.2.5-83.el7.centos.1 will be installed
--> Processing Dependency: dhcp-libs( x86-64) = 12 :4.2.5-83.el7.centos.1 for package: 12 :dhcp-4.2.5-83.el7.centos.1.x86_64
--> Processing Dependency: dhcp-common = 12 :4.2.5-83.el7.centos.1 for package: 12 :dhcp-4.2.5-83.el7.centos.1.x86_64
--> Processing Dependency: libisc-export.so.169( ) ( 64bit) for package: 12 :dhcp-4.2.5-83.el7.centos.1.x86_64
--> Processing Dependency: libdns-export.so.1102( ) ( 64bit) for package: 12 :dhcp-4.2.5-83.el7.centos.1.x86_64
--> Running transaction check
---> Package bind-export-libs.x86_64 32 :9.11.4-26.P2.el7_9.10 will be installed
---> Package dhcp-common.x86_64 12 :4.2.5-42.el7.centos will be updated
--> Processing Dependency: dhcp-common = 12 :4.2.5-42.el7.centos for package: 12 :dhclient-4.2.5-42.el7.centos.x86_64
---> Package dhcp-common.x86_64 12 :4.2.5-83.el7.centos.1 will be an update
---> Package dhcp-libs.x86_64 12 :4.2.5-42.el7.centos will be updated
---> Package dhcp-libs.x86_64 12 :4.2.5-83.el7.centos.1 will be an update
--> Running transaction check
---> Package dhclient.x86_64 12 :4.2.5-42.el7.centos will be updated
---> Package dhclient.x86_64 12 :4.2.5-83.el7.centos.1 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
Package Arch Version Repository Size
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
Installing:
dhcp x86_64 12 :4.2.5-83.el7.centos.1 updates 515 k
Installing for dependencies:
bind-export-libs x86_64 32 :9.11.4-26.P2.el7_9.10 updates 1.1 M
Updating for dependencies:
dhclient x86_64 12 :4.2.5-83.el7.centos.1 updates 286 k
dhcp-common x86_64 12 :4.2.5-83.el7.centos.1 updates 177 k
dhcp-libs x86_64 12 :4.2.5-83.el7.centos.1 updates 133 k
Transaction Summary
== == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == ==
Install 1 Package ( +1 Dependent package)
Upgrade ( 3 Dependent packages)
Total download size: 2.2 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
( 1 /5) : dhclient-4.2.5-83.el7.centos.1.x86_64.rpm | 286 kB 00:00:00
( 2 /5) : dhcp-4.2.5-83.el7.centos.1.x86_64.rpm | 515 kB 00:00:00
( 3 /5) : dhcp-common-4.2.5-83.el7.centos.1.x86_64.rpm | 177 kB 00:00:00
( 4 /5) : bind-export-libs-9.11.4-26.P2.el7_9.10.x86_64.rpm | 1.1 MB 00:00:01
( 5 /5) : dhcp-libs-4.2.5-83.el7.centos.1.x86_64.rpm | 133 kB 00:00:00
------------------------------------------------------------------------------------------------------------------------
Total 1.0 MB/s | 2.2 MB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 12 :dhcp-libs-4.2.5-83.el7.centos.1.x86_64 1 /8
Updating : 12 :dhcp-common-4.2.5-83.el7.centos.1.x86_64 2 /8
Installing : 32 :bind-export-libs-9.11.4-26.P2.el7_9.10.x86_64 3 /8
Installing : 12 :dhcp-4.2.5-83.el7.centos.1.x86_64 4 /8
Updating : 12 :dhclient-4.2.5-83.el7.centos.1.x86_64 5 /8
Cleanup : 12 :dhclient-4.2.5-42.el7.centos.x86_64 6 /8
Cleanup : 12 :dhcp-common-4.2.5-42.el7.centos.x86_64 7 /8
Cleanup : 12 :dhcp-libs-4.2.5-42.el7.centos.x86_64 8 /8
Verifying : 32 :bind-export-libs-9.11.4-26.P2.el7_9.10.x86_64 1 /8
Verifying : 12 :dhcp-common-4.2.5-83.el7.centos.1.x86_64 2 /8
Verifying : 12 :dhcp-4.2.5-83.el7.centos.1.x86_64 3 /8
Verifying : 12 :dhcp-libs-4.2.5-83.el7.centos.1.x86_64 4 /8
Verifying : 12 :dhclient-4.2.5-83.el7.centos.1.x86_64 5 /8
Verifying : 12 :dhclient-4.2.5-42.el7.centos.x86_64 6 /8
Verifying : 12 :dhcp-libs-4.2.5-42.el7.centos.x86_64 7 /8
Verifying : 12 :dhcp-common-4.2.5-42.el7.centos.x86_64 8 /8
Installed:
dhcp.x86_64 12 :4.2.5-83.el7.centos.1
Dependency Installed:
bind-export-libs.x86_64 32 :9.11.4-26.P2.el7_9.10
Dependency Updated:
dhclient.x86_64 12 :4.2.5-83.el7.centos.1 dhcp-common.x86_64 12 :4.2.5-83.el7.centos.1
dhcp-libs.x86_64 12 :4.2.5-83.el7.centos.1
Complete!
2.复制dhcp示例配置文件
[ root@serer01 ~]
cp: overwrite ‘/etc/dhcp/dhcpd.conf’? yes
[ root@serer01 ~]
3.修改dhcp配置文件
[ root@serer01 ~]
ddns-update-style interim;
ignore client-updates;
subnet 192.168 .3.0 netmask 255.255 .255.0 {
option routers 192.168 .3.254;
option subnet-mask 255.255 .255.0;
option nis-domain "my.dhcp.com" ;
option domain-name "my.dhcp.com" ;
option domain-name-servers 192.168 .3.169;
option time-offset -18000;
range dynamic-bootp 192.168 .3.100 192.168 .3.200;
default-lease-time 21600 ;
max-lease-time 43200 ;
host ns {
next-server marvin.redhat.com;
hardware ethernet 12 :34:56:78:AB:CD;
fixed-address 207.175 .42.254;
}
}
[ root@serer01 ~]
4.绑定网卡
在/etc/sysconfig/dhcpd中添加一行
< span style = "font-size:14px;" > DHCPDARGS= eth0 < /span>
5.重启dhcp服务
systemctl restart dhcpd
6.查看dhcp服务状态
[ root@serer01 ~]
● dhcpd.service - DHCPv4 Server Daemon
Loaded: loaded ( /usr/lib/systemd/system/dhcpd.service; disabled; vendor preset: disabled)
Active: active ( running) since Mon 2022 -10-17 02:08:15 CST; 39s ago
Docs: man:dhcpd( 8 )
man:dhcpd.conf( 5 )
Main PID: 5268 ( dhcpd)
Status: "Dispatching packets..."
Memory: 4 .8M
CGroup: /system.slice/dhcpd.service
└─5268 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid
五、测试网卡获取DHCP分发地址