linux中yum源安装dhcp,24.Linux系统下动态网络源部署方法(dhcpd)
1.安装dhcp软件
注意:安装时需要有配置好的yum仓库,关于yum仓库的配置,祥见Linux下系统的软件安装以及yum源配置(yum仓库搭建、yum命令、rpm命令)
[root@servser ~]# yum install dhcp -y
Loaded plugins: langpacks
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.2.5-27.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
dhcp x86_64 12:4.2.5-27.el7 rhel7.0 506 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 506 k
Installed size: 1.4 M
Downloading packages:
dhcp-4.2.5-27.el7.x86_64.rpm | 506 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 12:dhcp-4.2.5-27.el7.x86_64 1/1
Verifying : 12:dhcp-4.2.5-27.el7.x86_64 1/1
Installed:
dhcp.x86_64 12:4.2.5-27.el7
Complete!
2.配置动态网络
注意:配置防火墙关闭或者将dhcp服务加入防火墙白名单,详见LInux下防火墙的基本管理(查看、火墙伪装、添加防火墙白名单)
[root@servser ~]# systemctl start dhcpd ##安装完成后打开dhcpd服务
[root@servser ~]# systemctl status dhcpd.service ##可以看到,服务打不开
dhcpd.service - DHCPv4 Server Daemon
Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; disabled)
Active: failed (Result: exit-code) since Mon 2019-02-18 11:52:33 EST; 13s ago
Docs: man:dhcpd(8)
man:dhcpd.conf(5)
Process: 31524 ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid (code=exited, status=1/FAILURE)
Main PID: 31524 (code=exited, status=1/FAILURE)
Feb 18 11:52:33 servser.westos.com dhcpd[31524]: you want, please write a su...n
Feb 18 11:52:33 servser.westos.com dhcpd[31524]: in your dhcpd.conf file for...t
Feb 18 11:52:33 servser.westos.com dhcpd[31524]: to which interface eth0 is ...*
Feb 18 11:52:33 servser.westos.com dhcpd[31524]: Feb 18 11:52:33 servser.westos.com dhcpd[31524]: Feb 18 11:52:33 servser.westos.com dhcpd[31524]: Not configured to listen on...!
Feb 18 11:52:33 servser.westos.com dhcpd[31524]: Feb 18 11:52:33 servser.westos.com dhcpd[31524]: This version of ISC DHCP is...e
Feb 18 11:52:33 servser.westos.com systemd[1]: dhcpd.service: main process e...E
Feb 18 11:52:33 servser.westos.com systemd[1]: Unit dhcpd.service entered fa....
Hint: Some lines were ellipsized, use -l to show in full.
[root@servser ~]# vim /etc/dhcp/dhcpd.conf ##打开配置文件,发现配置文件为空,需要查看模板
[root@servser ~]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
[root@servser ~]# cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf ##复制模板过来
cp: overwrite ‘/etc/dhcp/dhcpd.conf’? y
[root@servser ~]# vim /etc/dhcp/dhcpd.conf ##编辑动态网络配置文件
##写入:
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks...
option domain-name "westos.com";
option domain-name-servers 172.25.68.100;
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;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
# This is a very basic subnet declaration.
subnet 172.25.68.0 netmask 255.255.255.0 {
range 172.25.68.101 172.25.68.200;
option routers 172.25.68.100;
}
##其中:
option domain-name "westos.com";
option domain-name-servers 172.25.68.100;
DNS,配置获取到网络的DNS服务域名和域名服务器的IP
default-lease-time 600;
默认租约时间
max-lease-time 7200;
最大租约时间
subnet 172.25.68.0
netmask 255.255.255.0
子网掩码
range 172.25.68.101 172.25.68.200;
可获取的动态IP范围
option routers 172.25.68.100;
获取到网络的网关
3.测试动态网络源:
[root@dhcp_test ~]# ifconfig ##查看当前已有的IP
eth0: flags=4163mtu 1500
inet 172.25.68.101 netmask 255.255.255.0 broadcast 172.25.68.255
inet6 fe80::5054:ff:fe00:440b prefixlen 64 scopeid 0x20
ether 52:54:00:00:44:0b txqueuelen 1000 (Ethernet)
RX packets 370 bytes 35553 (34.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 338 bytes 36819 (35.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163mtu 1500
ether 52:54:00:24:53:64 txqueuelen 1000 (Ethernet)
RX packets 156 bytes 10332 (10.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10loop txqueuelen 0 (Local Loopback)
RX packets 275 bytes 22000 (21.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 275 bytes 22000 (21.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@dhcp_test ~]# cd /etc/sysconfig/network-scripts/ ##切换目录
[root@dhcp_test network-scripts]# ls
ifcfg-eth0-1 ifdown-ppp ifup-eth ifup-sit
ifcfg-lo ifdown-routes ifup-ippp ifup-Team
ifdown ifdown-sit ifup-ipv6 ifup-TeamPort
ifdown-bnep ifdown-Team ifup-isdn ifup-tunnel
ifdown-eth ifdown-TeamPort ifup-plip ifup-wireless
ifdown-ippp ifdown-tunnel ifup-plusb init.ipv6-global
ifdown-ipv6 ifup ifup-post network-functions
ifdown-isdn ifup-aliases ifup-ppp network-functions-ipv6
ifdown-post ifup-bnep ifup-routes
[root@dhcp_test network-scripts]# cp ifcfg-eth0-1 ifcfg-eth1 ##复制配置文件
[root@dhcp_test network-scripts]# vim ifcfg-eth1 ##编辑配置文件
##写入
TYPE=Ethernet
BOOTPROTO=dhcp
NAME=eth1
ONBOOT=yes
DEVICE=eth1
[root@dhcp_test network-scripts]# systemctl restart network重启网络服务
[root@dhcp_test network-scripts]# ifconfig
eth0: flags=4163mtu 1500
inet 172.25.68.101 netmask 255.255.255.0 broadcast 172.25.68.255
inet6 fe80::5054:ff:fe00:440b prefixlen 64 scopeid 0x20
ether 52:54:00:00:44:0b txqueuelen 1000 (Ethernet)
RX packets 1469 bytes 130431 (127.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1048 bytes 121340 (118.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163mtu 1500
inet 172.25.68.108 netmask 255.255.255.0 broadcast 172.25.68.255 ##可以看到eth1成功获得到了动态IP
inet6 fe80::5054:ff:fe24:5364 prefixlen 64 scopeid 0x20
ether 52:54:00:24:53:64 txqueuelen 1000 (Ethernet)
RX packets 360 bytes 20100 (19.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 22 bytes 3891 (3.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10loop txqueuelen 0 (Local Loopback)
RX packets 275 bytes 22000 (21.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 275 bytes 22000 (21.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
##查看日志也可以看到动态IP获取的来源
Feb 18 12:50:43 localhost NetworkManager: DHCPREQUEST on eth1 to 255.255.255.255 port 67 (xid=0x410b580d)
Feb 18 12:50:43 localhost dhclient[4482]: DHCPACK from 172.25.68.100 (xid=0x410b580d)
Feb 18 12:50:43 localhost NetworkManager: DHCPACK from 172.25.68.100 (xid=0x410b580d)
Feb 18 12:50:43 localhost dhclient[4482]: bound to 172.25.68.108 -- renewal in 234 seconds.
Feb 18 12:50:43 localhost NetworkManager: bound to 172.25.68.108 -- renewal in 234 seconds.
Feb 18 12:50:43 localhost NetworkManager[664]: (eth1): DHCPv4 state changed preinit -> reboot
Feb 18 12:50:43 localhost NetworkManager[664]: address 172.25.68.108
Feb 18 12:50:43 localhost NetworkManager[664]: plen 24 (255.255.255.0)
Feb 18 12:50:43 localhost NetworkManager[664]: gateway 172.25.68.100
Feb 18 12:50:43 localhost NetworkManager[664]: server identifier 172.25.68.100
Feb 18 12:50:43 localhost NetworkManager[664]: lease time 600
Feb 18 12:50:43 localhost NetworkManager[664]: nameserver '172.25.68.100'
Feb 18 12:50:43 localhost NetworkManager[664]: domain name 'westos.com'
linux中yum源安装dhcp,24.Linux系统下动态网络源部署方法(dhcpd)相关推荐
- linux中yum怎么安装服务器,yum安装(linux如何安装yum)
1.使用yum安装和卸载软件,有个前提是yum安装的软件包都是rpm格式的. 安装的命令是,yum install ~ 删除的命令是,yum remove ~ 其中~ 代表软件名2.用yum查询想安. ...
- linux中wps默认安装目录,在Linux中安装和使用wps
永中office始终感觉有点别扭,今天又尝试了下装wps,最终成功了,方法如下 1.解决缺少libstdc++.so.6(GLIBCXX_3.4.14) 在CentOS6.4上安装金山wps k ...
- linux中运行yarn命令,在CentOS 8系统下安装和使用Yarn的方法
本文介绍在CentOS 8 Linux操作系统下安装和使用Yarn的方法.Yarn是与npm兼容的JavaScript软件包管理器,可帮助你自动化安装.更新.配置和删除npm软件包的过程.它的创建是为 ...
- 在linux中dns不安装coching,ubuntu 8.04下openldap的安装和使用
ubuntu 8.04上openldap的安装和使用 1.安装openldap. $ sudo apt-get install slapd ldap-utils 2.配置openldap. $ sud ...
- linux重启kvm服务命令,linux中kvm的安装及快照管理
一.kvm的安装及状态查看 1.安装软件 yum -y install kvm virt-manager libvirt 2.启动libvirtd 报错,升级device-mapper-libs yu ...
- Linux中常用软件安装
Linux中常用软件安装 0 软件安装命令 rpm命令 yum命令 1 JDK安装 2 Mysql安装 0 MySQL安装与卸载 (新增于 2021-06-06) 1 卸载 yum方式 rpm方式 2 ...
- Linux中SVN的安装与使用
安装 SVN SVN安装在公网IP为x.x.x.x的服务器上. 第一步,可以使用命令检查系统是否安装SVN. 大多数GNU/Linux发行版系统自带SVN,所以可能SVN已经安装在系统上,需要检查系统 ...
- Linux中yum执行yum -y install gcc 报错 解决方案
Linux中yum执行yum -y install gcc 报错 解决方案 本人实际遇到的问题,已亲测正式环境,为防止下次在遇到,在这里做个记录,遇到此问题的小伙伴可以参考此文章. 文章摘自其它网友博 ...
- Linux中yum和apt-get
概述 一般来说著名的linux系统基本上分两大类: 1.RedHat系列:Redhat.Centos.Fedora等 2.Debian系列:Debian.Ubuntu等 RedHat 系列 -包管理工 ...
最新文章
- gst-crypto GStreamer插件
- Storm具体的解释(二)、成为第一Storm申请书
- 他,跳槽季用这样的方法复习进了阿里
- VirtualBox 虚拟机转换为KVM虚拟机
- pain point
- 使用 C++0x 时 make_shared 完美转发构造函数参数的测试编译器
- Netty私有栈协议
- 前端学习(3036):vue+element今日头条管理-复习
- vue-router 路由跳转
- [视频]Silverlight for Windows Phone 7基本开发过程以及Push Button控件的使用
- seo爬虫工具 php,爬虫工具有哪些(爬虫网页分析工具)
- 检测到在集成的托管管道模式下不适用的ASP.NET设置的解决方法(非简单设置为【经典】模式)。 - CatcherX...
- Slider控件的使用方法
- curl basic 认证
- SwiftyJSON的使用详解
- 不使用imrotate实现图像旋转(点操作实现)
- docker安装时报服务失败,因为控制进程退出并带有错误代码
- trivy【1】漏洞扫描工具安装
- 如何清除计算机搜索框内的搜索历史记录,如何清除搜索框中的网站访问历史记录...
- java中文转换数字_Java 中文数字转换为阿拉伯数字