centos 没有dhclient?centos7安装第三方软件

本篇文章给大家谈谈centos 没有dhclient,以及centos7安装第三方软件对应的知识点,文章可能有点长,但是希望大家可以阅读完,增长自己的知识,最重要的是希望对各位有所帮助,可以解决了您的问题,不要忘了收藏本站喔。

CentOS7网络设置修复

服务器有两个网卡enp7s0和enp8s0   

服务器需要通过enp8s0和互联网联通,互联网为笔记本转接

通过centos7界面修改ip,失败;

通过centos7的网络配置文件/etc/sysconfig/network-scripts/ifcfg-enp8s0修改ip设置

设置如下:

1.启动 service network start报错,通过journalctl-xe查看如下

-- Defined-By: systemd

-- Support:

--

-- Unit fprintd.service has begun starting up.

12月 29 19:31:12 crrchost dbus-daemon[851]: dbus[851]: [system] Successfully activated service'net.reactivated.Fprint'

12月 29 19:31:12 crrchost dbus[851]: [system] Successfully activated service'net.reactivated.Fprint'

12月 29 19:31:12 crrchost systemd[1]: Started Fingerprint Authentication Daemon.

-- Subject: Unit fprintd.service has finished start-up

-- Defined-By: systemd

-- Support:

--

-- Unit fprintd.service has finished starting up.

--

-- The start-up result is done.

12月 29 19:31:12 crrchost fprintd[6685]: Launching FprintObject

12月 29 19:31:12 crrchost fprintd[6685]:** Message: D-Bus service launched with name: net.reactivated.Fprint

12月 29 19:31:12 crrchost fprintd[6685]:** Message: entering main loop

12月 29 19:31:18 crrchost polkitd[835]: Operator of unix-session:1 successfully authenticated as unix-user:windfarm to gain TEMPORARY authorization for action org.freedesktop.systemd1.manage-units for system-bus

12月 29 19:31:18 crrchost systemd[1]: Starting LSB: Bring up/down networking...

-- Subject: Unit network.service has begun start-up

-- Defined-By: systemd

-- Support:

--

-- Unit network.service has begun starting up.

12月 29 19:31:18 crrchost network[6693]:正在打开环回接口: [ 确定  ]

12月 29 19:31:18 crrchost network[6693]:正在打开接口 enp7s0:

12月 29 19:31:24 crrchost network[6693]:正在确定 enp7s0的 IP信息...失败:不存在链接。检查电缆?

12月 29 19:31:24 crrchost network[6693]: [失败]

12月 29 19:31:24 crrchost network[6693]:正在打开接口 enp8s0: RTNETLINK answers: File exists

12月 29 19:31:25 crrchost network[6693]: [ 确定  ]

12月 29 19:31:25 crrchost network[6693]: RTNETLINK answers: File exists

12月 29 19:31:25 crrchost network[6693]: RTNETLINK answers: File exists

12月 29 19:31:25 crrchost network[6693]: RTNETLINK answers: File exists

12月 29 19:31:25 crrchost network[6693]: RTNETLINK answers: File exists

12月 29 19:31:25 crrchost network[6693]: RTNETLINK answers: File exists

12月 29 19:31:25 crrchost network[6693]: RTNETLINK answers: File exists

12月 29 19:31:25 crrchost network[6693]: RTNETLINK answers: File exists

12月 29 19:31:25 crrchost network[6693]: RTNETLINK answers: File exists

12月 29 19:31:25 crrchost network[6693]: RTNETLINK answers: File exists

12月 29 19:31:25 crrchost systemd[1]: network.service: control process exited, code=exited status=1

12月 29 19:31:25 crrchost systemd[1]: Failed to start LSB: Bring up/down networking.

-- Subject: Unit network.service has failed

-- Defined-By: systemd

-- Support:

--

-- Unit network.service has failed.

--

-- The result is failed.

12月 29 19:31:25 crrchost systemd[1]: Unit network.service entered failed state.

12月 29 19:31:25 crrchost systemd[1]: network.service failed.

12月 29 19:31:25 crrchost polkitd[835]: Unregistered Authentication Agent for unix-process:6669:319312(system bus name:1.263, object path/org/freedesktop/PolicyKit1/AuthenticationAgent, locale zh_CN.UTF-8)(d

3.systemctl status network.service查看如下:

● network.service- LSB: Bring up/down networking

  Loaded: loaded(/etc/rc.d/init.d/network; bad; vendor preset: disabled)

  Active: failed(Result: exit-code) since六 2018-12-29 18:38:17 CST; 1min 24s ago

   Docs: man:systemd-sysv-generator(8)

  Process: 909 ExecStart=/etc/rc.d/init.d/network start(code=exited, status=1/FAILURE)

12月 29 18:38:06 crrchost systemd[1]: Starting LSB: Bring up/down networking...

12月 29 18:38:06 crrchost network[909]:正在打开环回接口: [ 确定  ]

12月 29 18:38:06 crrchost network[909]:正在打开接口 enp7s0:

12月 29 18:38:12 crrchost network[909]:正在确定 enp7s0的 IP信息...失败:…?

12月 29 18:38:12 crrchost network[909]: [失败]

12月 29 18:38:17 crrchost network[909]:正在打开接口 enp8s0: [ 确定  ]

12月 29 18:38:17 crrchost systemd[1]: network.service: control process exi...=1

12月 29 18:38:17 crrchost systemd[1]: Failed to start LSB: Bring up/down n...g.

12月 29 18:38:17 crrchost systemd[1]: Unit network.service entered failed...e.

12月 29 18:38:17 crrchost systemd[1]: network.service failed.

Hint: Some lines were ellipsized, use-l to show in full.

1.参考网络方法停用NetworkManager,依旧报错

   systemctl stop NetworkManager

    systemctl disable NetworkManager

2.比对两个网卡的MAC地址和配置文件的MAC地址

   a.查看mac地址配置,ipconfig

   b.查看配置文件中的macd地址是否匹配,ifcfg-enp8s0和ifcfg-enp7s0,

    按照网络方法增加一行HWADDR=ipconfig查询到的对应网卡MAC地址;

   c.重启network服务依旧报错;

3.通过GUI界面查看网络,提示“系统的网络服务与此版本的网络管理器不兼容”

  这与之前停掉NetworkManager有关,此处不表;

4.因为ifcfg-enp7s0实际上没有插网线,修正其配置文件如下:

   ONBOOT=no

  重新启动服务后网络正常;

5.检查网络

1.network和NetworkManager不同,通过界面和通过配置文件,可能会导致配置混乱,且NetworkManager有些程序不支持,需要停用;

2.BOOTPROTO=none虽然可以表示静态ip,但是如果要启用,必须设置其为

BOOTPROTO=static或BOOTPROTO=dhcp

3.一个网卡没哟被启用,也就是没有设置动态ip或静态ip,是无法被初始化的,不能设置ONBOOT=yes

In Centos7.0 disabling NetworkManager will leave a dhcp client running configured for NetworkManager. This causes the error message RTNETLINK answers: File exists when the network service is started.

The stale dhclient process has the additional"benefit" that when the lease expires your dhclientwill choke, since it cannot reach NetWorkManager, thus removing your IP address.

If you grep for it, you will see that it points to a NetWorkManager configuration file.

[root@host~]# ps-ef| grep dhc

root    1865  792  0 Apr28?     00:00:00/sbin/dhclient-d-sf\

/usr/libexec/nm-dhcp-helper-pf/var/run/dhclient-eno1.pid-lf\

/var/lib/NetworkManager/dhclient-c96e56d3-a4c9-4a87-85ca-93dc0ca268f2-eno1.lease\

-cf/var/lib/NetworkManager/dhclient-eno1.conf eno1

So what you can do is kill the dhclient and only then start your network service.

centos网络配置方法手动设置自动获取

不知道为什么最近一段时间网络特别的慢,还老是断,断的时候,局域网都连不上,当我手动设置一下ip后就可以了,搞得我很无语。下面是2种设置网络连接的方法,在说怎么设置前,一定要做好备份工作,特别是对于新手来说,如果修改的地方多了,你也会搞晕的,所以修改一个文件前一定要备份

一,修改文件来设置网络连接

1,自动获取IP的方法

自动获取根4个文件有关系

a),/etc/sysconfig/network-scripts/ifcfg-eth0

[zhangy@localhost network-scripts]$ cat ifcfg-eth0

# Marvell Technology Group Ltd. 88E8039 PCI-E Fast Ethernet Controller

DEVICE=eth0//由eth0来启动

BOOTPROTO=dhcp//获取IP的方式是自动获取,static是固定IP,none是手动

HWADDR=00:16:D3:A2:F6:09//网卡的物理地址

IPV6INIT=yes//是否支持IP6

IPV6_AUTOCONF=yes//IP6是否自动配置

ONBOOT=yes//启动时网络接口是否有效

b),/etc/sysconfig/network

[zhangy@localhost network-scripts]$ cat/etc/sysconfig/network

NETWORKING=yes//网络是否可用

NETWORKING_IPV6=yes

HOSTNAME=localhost.localdomain//主机名,主机名在/etc/hosts里面配置

c),/etc/hosts

[zhangy@localhost network-scripts]$ cat/etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1 localhost.localdomain localhost//根/etc/resolv.conf中search要对应,localhost.localdomain

::1 localhost6.localdomain6 localhost6

d),/etc/resolv.conf

[zhangy@localhost network-scripts]$ cat/etc/resolv.conf

; generated by/sbin/dhclient-script

nameserver 192.168.1.1//DNS服务器对应的IP

search localdomain//搜索要找的域名,在/etc/hosts里面设定的有

2,手动设定

手动设定只要修改三个文件就可以了

a),/etc/sysconfig/network

[zhangy@localhost network-scripts]$ cat/etc/sysconfig/network

NETWORKING=yes

NETWORKING_IPV6=yes

#HOSTNAME=localhost.localdomain//为什么要把主机名注释掉,一般先解析主机名或者域名,再解析DNS

GATEWAY=192.168.1.1//加上网关

b),/etc/sysconfig/network-scripts/ifcfg-eth0

[zhangy@localhost network-scripts]$ cat ifcfg-eth0

# Marvell Technology Group Ltd. 88E8039 PCI-E Fast Ethernet Controller

DEVICE=eth0

BOOTPROTO=none//启动为手动

BROADCAST=192.168.1.255

HWADDR=00:16:D3:A2:F6:09

IPADDR=192.168.1.108//设置的IP

NETMASK=255.255.255.0//子网掩码

NETWORK=192.168.1.0

IPV6INIT=yes

IPV6_AUTOCONF=yes

ONBOOT=yes

TYPE=Ethernet//网络类型

c),/etc/resolv.conf

[zhangy@localhost network-scripts]$ cat/etc/resolv.conf

#; generated by/sbin/dhclient-script

#nameserver 192.168.1.1

#search localdomain

nameserver 116.228.111.118//加上主DNS

nameserver 180.168.255.18//加上次DNS

二,命令方法

netconfig是网络管理工具,RH装完机后,系统中就会有netconfig。虽然centos也是由RH演化来的,但是没有啊。不过没关系我们可能自己来装。

[zhangy@localhost download]$ wget

[zhangy@localhost download]$ rpm-ivh netconfig-0.8.24-1.2.2.1.i386.rpm

error: can't create transaction lock on/var/lib/rpm/__db.000

[zhangy@localhost download]$ su root//别忘了要用root账户,不然就会报上面的错误

口令:

[root@localhost download]# rpm-ivh netconfig-0.8.24-1.2.2.1.i386.rpm

Preparing...########################################### [100%]

1:netconfig########################################### [100%]

[root@localhost download]# whereis netconfig//查看一下netconfig在什么地方

netconfig:/usr/sbin/netconfig

复制代码代码如下:

[root@localhost]# netconfig--help

--bootproto=(dhcp|bootp|none) Boot protocol to use//获取IP的方式,dhcp是自,bootp固定IP,none手动

--gateway=STRING Network gateway//指定网关

--ip=STRING IP address//指定IP地址

--nameserver=STRING Nameserver//指定DNS

--netmask=STRING Netmask//指定子网掩码

--hostname=STRING Hostname//指定主机名

--domain=STRING Domain name//指定域名

-d,--device=STRING Network device//指定网络设备

--nodns No DNS lookups//没有DNS查询

--hwaddr=STRING Ethernet hardware address//指定网卡的物理地址

--description=STRING Description of the device//描述

Help options:

-?,--help Show this help message

--usage Display brief usage message

1,自动获取IP

[root@localhost download]#/usr/sbin/netconfig-d eth0--bootproto=dhcp

2,手动设置IP

[root@localhost download]#/usr/sbin/netconfig-d eth0--bootproto=none--ip=192.168.1.108--netmask=255.255.255.0--gateway=192.168.1.1--nameserver=116.228.111.118

三,配置中遇到的一些问题

1,重启网络不起作用

service network restart重启后还是无法连接网络,我可以确定我配置的没问题,重新启动一下电脑就可以了。

2,备份ifcfg-eth0文件的时候要注意,前面不要带有ifcfg-eth0

ifcfg-eth0

上图中我把自动获取IP的配置文件ifcfg-eth0作了备份,名子为ifcfg-eth0_dhcp,重新启动网络的时候,这个文件依然被执行了,开始的时候,我并没注意到这一点,等我ifconfig查看网络的时候,发现我做的修改根本没有启作用,并且/etc/resolv.conf里面做的修改又被盖了。所以备份的时候,前面不要带有ifcfg-eth0

linux启动dhcp服务器的命令linux启动dhcp

dhcp服务启动命令?

启用DHCP的方法是:

在linux中,dhcp服务器的配置比较简单,只需要掌握/etc/dhcpd.conf的配置即可。另外相关的辅助配置文件/lib/dhcpd.leases用于记录已经分配出去的Ip地址信息。

1.首先打开计算机管理,找到DHCPclient服务;

2.然后设置该服务的启动类型为自动;

3.接着打开【网络和Internet】选项,找到本地连接;

4.最后勾选【自动获得IP地址】选项即可。

linux怎么启动dhcpv4?

先用yum安装DHCP服务,命令:yum-yinstalldhcp启动:servicedhcpstart

linux下如何开机自启动dhcp服务?

1,通过编辑/etc/rc.local文件来使dhcp服务开机自启动

使用命令vi/etc/rc.local,

然后在文件最后一行添加“sudo/etc/init.d/dhcp3-serverstart”就能使dhcp服务开机自启动。

2,使用crontab任务提交计划

先写一个简单的检查dhcp服务是否启动了的脚本a.sh:

#!/bin/bash ps-ef|grepdhcp|grep-vgrep if then exit0 else sudo/etc/init.d/dhcp3-serverstart>/dev/null2>1 fi

如果在用户目录下没有cron文件,使用vi新建一个my.cron的crontab文件,将以下内容写进去:

*/5****bash$HOME/a.sh

然后crontabmy.corn提交,这样系统就会在每5分钟运行一次a.sh脚本,检测dhcp服务已经启动了,如果没有启动或者停止了就会再启动一次。

3,注册系统服务

chkconfig--add服务名称(首先,添加为系统服务,注意add前面有两个横杠)

chkconfig-leve启动级别服务名on

(说明,3级别代表在命令行模式启动,5级别代表在图形界面启动,on表示开启)

chkconfig-leve启动级别服务名off

(说明,off表示关闭自启动)

例如注册dhcp为系统服务并在开机时自启动:

chkconfig--adddhcp chkconfig-level3dhcpon

总结一下:第一种方法其实是将指定服务设置为开机自启动,第三种方法是将服务升级为系统服务并且设置为开机时启动,而第二种方法对于那些最好或者必须开机启动的服务最好不要使用,但是可以使用crontab来实时监测服务是否在线。

如何判断linuxDHCP服务器状态/关闭/开启命令?

1.查看是否设置开机启动

chkconfig--list|grepdhcpd

2.查看端口是否打开

netstat-anulp|grep:67

3.查看服务状态

/etc/

init.d/dhcpd

status

【查看是否运行dhcp服务:psaux|grepdhcp|grep-vgrep】

4:关闭dhcpd

/etc/

init.d/dhcpd

stop

5:开启hdcpd

/etc/

init.d/dhcpd

start

DHCP服务介绍及Linux下DHCP服务的管理配置?

1.DHCP服务

DHCP是DynamicHostConfigurationProtocol,动态主机配置协议,是用来在物理网络给主机分配ip地址的一种方式,区别于bootp,一次分配终身使用的缺点。

DHCP提出的租约的概念,使得可以根据需要动态确定主机需要的IP地址,并且IP地址可以循环使用。

2.DHCP结构

DHCP是典型的C/S结构,需要服务端启动守护进程来保证来自client段的请求能被响应,DHCP的工作原理如下:

可以通过DORA来记忆:

Client:DHCPDISCOVER#客户端向相同网络发送广播包,企图寻找DHCP服务器

Server:DHCPOFFER#如果DHCP服务段收到DISCOVER包,则向客户端回复OFFER广播包

Client:DHCPREQUEST#客户端收到来自DHCP的OFFER广播包后,则确定DHCP服务器,继续向DHCP服务器发送REQUEST包,来申请ip信息

Server:DHCPACK#DHCP服务端向客户端发送ACK包,携带ip和租约信息给客户端,DHCP发现过程结束

注意:dhcp在跨网段的路由器另一侧,则路由器需要开启dhcprelay来支持转发客户端DISCOVER的广播包给DHCP服务器,这些通过路由器的转发,都是单播

因为路由器和dhcp之间的连接是有ip信息的。

DHCP服务端端口UDP67

DHCP客户端端口UDP68

DHCPreservation:地址保留:

专用于某特定客户端的地址,不应该使用地址池中的地址;优先于地址池中的地址;

3.Linux下DHCP服务安装配置

由于CentOS6/7的系统管理机制不同,所以开机自启动服务的方式有所不同,但是配置文件,帮助文档大同小异

3.1CentOS6下DHCP安装:

#yuminstalldhcp

#通过rpm-qldhcp来查询hdcp包所创建安装的文件,我们可以分析他的使用方式:

这里列举几个比较重要的文件:

#DHCP服务配置文件:

/etc/dhcp/dhcpd.conf

/etc/dhcp/dhcpd6.conf

#服务脚本,控制dhcp服务的启动,关闭,状态查询,reload等

/etc/rc.d/init.d/dhcpd

/etc/rc.d/init.d/dhcpd6

/etc/rc.d/init.d/dhcrelay

/etc/rc.d/init.d/dhcrelay6

#dhcp命令参数配置文件:此文件内容提供一些区段给dhcpd守护进程在系统引导时使用,dhcpd守护进程使用DHCP及BOOTP协议为主机自动分配IP地址

/etc/sysconfig/dhcpd

/etc/sysconfig/dhcpd6

/etc/sysconfig/dhcrelay

/etc/sysconfig/dhcrelay6

#dhcp二进制程序

/usr/sbin/dhcpd

/usr/sbin/dhcrelay

#dhcp的ip地址租约库,可以查到ip分配情况

/var/lib/dhcpd/dhcpd.leases

/var/lib/dhcpd/dhcpd6.leases

4.1CentOS6下dhcp服务配置文件管理:

4.1.1首先编辑dhcp主配置文件:

/etc/dhcp/dhcpd.conf

optiondomain-name"richie.com";#dhcp主机名

optiondomain-name-servers192.168.229.141;#名称服务器的地址

default-lease-time600;#默认租约秒数

max-lease-time7200;#最大租约秒数

log-facilitylocal7;#log级别

subnet192.168.229.0netmask255.255.255.0{

range192.168.229.201192.168.229.220;#可供分配的ip段

optionrouters192.168.229.1,192.168.229.2;#如果在最近配置的optionrouters那就直接饮用,如果没有,那就会自动继承上一级的option

}#子网配置格式

当编辑完,保存退出,可以使用这个命令来检测语法错误:

servicedhcpdconfigtest

4.1.2配置ip地址预留:

需要在subnet{}内部,配置host{}格式如下:

subnet192.168.229.0netmask255.255.255.0{

hostwindows1{

hardwareethernet00:0c:29:0:f3:44;

fixed-address192.168.229.222;

optionrouters192.168.0.1#这里可以针对这台机器设置optionrouters的值,而不用继承上一级的网关信息

}

}

最后,保存退出

servicedhcpdforce-reload

测试效果:

linuxclient:

dhclient-deth0

windowclient:

ipconfig/renew

4.1.3配置开机自启动:

还是老命令chkconfigdhcpdon,默认会将init级别2,3,4,5都设置为开机自启动,也可以使用chkconfig--level2,3,4来自己指定需要的运行级别自启

4.1.4管理dhcp服务

servicedhcpd{start|stop|restart|force-reload|condrestart|try-restart|configtest|status}

4.2CentOS7下的DHCP服务管理

4.2.1配置文件:

同CentOS6上的配置,参见4.1.1

4.2.2配置ip地址预留:

同CentOS6上的配置,参见4.1.2

4.2.3配置开机自启动:

由于CentOS6/7的系统服务管理机制的不同,CentOS7引入了systemd来管理所有的服务,所以不能再使用chkconfig命令来设置,需要使用:

#systemctlis-enabledDAEMON.service查看dhcp服务状态,相当于C5的chkconfig--listdhcpd

#systemctlenableDAEMON.service启用开机自启动dhcp服务,相当于C5的chkconfigdhcpdon

#systemctldisableDAEMON.service禁用开机自启动dhcp服务,相当于C5的chkconfigdhcpdoff

4.2.4管理dhcp服务

#systemctl{start|stop|restart|status}DAEMON.service

5.DHCP配置命令总结

一个简单dhcp服务的配置文件至少需要包含如下的配置信息:

dhcpd.conf

optiondomain-name

optiondomain-name-servers

optionrouters

subnetNETWORKnetmaskMASK{

rangeSTART_IPEND_IP;

hostHOSTID{

hardwareethernet00:11:22:33:44:55;

fixed-addressIP;

}

}

========================================================

例子:

dhcpd.conf

optiondomain-name"richie.com";

optiondomain-name-servers192.168.229.141;

default-lease-time600;

max-lease-time7200;

log-facilitylocal7;

subnet192.168.229.0netmask255.255.255.0{

range192.168.229.201192.168.229.220;

optionrouters192.168.229.1,192.168.229.2;

hostwindows1{

hardwareethernet00:0c:29:30:f3:44;

fixed-address192.168.229.211;

}

阅读剩余
THE END