CentOs7无法使用ifconfig命令,无法查看ip地址
原文地址:https://www.biaodianfu.com/centos-7-network-problem.htmlCentOS 发布已经很久了,由于本次版本变动比较大,特别是systemd的加入,所以先前一直使用的是centos 6.7版本。今天抽空在虚拟机上安装了CentOS 7,在安装完成后使用 yum update -y 进行系统更新,返回了错误信息:1234567891011121
原文地址:https://www.biaodianfu.com/centos-7-network-problem.html
CentOS 发布已经很久了,由于本次版本变动比较大,特别是systemd的加入,所以先前一直使用的是centos 6.7版本。今天抽空在虚拟机上安装了CentOS 7,在安装完成后使用 yum update -y 进行系统更新,返回了错误信息:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
Loaded
plugins
:
fastestmirror
,
priorities
,
security
Setting
up
Update
Process
Determining
fastest
mirrors
Could
not
retrieve
mirrorlist
http
:
//mirrorlist.centos.org/?release=6&arch=x86_64&repo=os&infra=stock error was
14
:
PYCURL
ERROR
6
-
"Couldn't resolve host 'mirrorlist.centos.org'"
Error
:
Cannot
find
a
valid
baseurl
for
repo
:
base
One
of
the
configured
repositories
failed
(
Unknown
)
,
and
yum
doesn
't
have enough cached data to continue. At this point the only safe
thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Disable the repository, so yum won'
t
use
it
by
default
.
Yum
will
then
just
ignore
the
repository
until
you
permanently
enable
it
again
or
use
--
enablerepo
for
temporary
usage
:
yum
-
config
-
manager
--
disable
<
repoid
>
4.
Configure
the
failing
repository
to
be
skipped
,
if
it
is
unavailable
.
Note
that
yum
will
try
to
contact
the
repo
.
when
it
runs
most
commands
,
so
will
have
to
try
and
fail
each
time
(
and
thus
.
yum
will
be
be
much
slower
)
.
If
it
is
a
very
temporary
problem
though
,
this
is
often
a
nice
compromise
:
yum
-
config
-
manager
--
save
--
setopt
=
<
repoid
>
.
skip_if_unavailable
=
true
Cannot
find
a
valid
baseurl
for
repo
:
base
/
7
/
x86_64
`
|
初步判断是网络问题,使用ifconfig查看下网络信息,但是发现:
1
|
-
bash
:
ifconfig
:
command
not
found
|
ifconfig也不能使用了,Google了下发现ifconfig命令已经被ip命令给取代了。具体ip命令的使用方法如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
ip
[选项
]
操作对象
{
link
|
addr
|
route
.
.
.
}
# ip link show # 显示网络接口信息
# ip link set eth0 upi # 开启网卡
# ip link set eth0 down # 关闭网卡
# ip link set eth0 promisc on # 开启网卡的混合模式
# ip link set eth0 promisc offi # 关闭网卡的混个模式
# ip link set eth0 txqueuelen 1200 # 设置网卡队列长度
# ip link set eth0 mtu 1400 # 设置网卡最大传输单元
# ip addr show # 显示网卡IP信息
# ip addr add 192.168.0.1/24 dev eth0 # 设置eth0网卡IP地址192.168.0.1
# ip addr del 192.168.0.1/24 dev eth0 # 删除eth0网卡IP地址
# ip route list # 查看路由信息
# ip route add 192.168.4.0/24 via 192.168.0.254 dev eth0 # 设置192.168.4.0网段的网关为192.168.0.254,数据走eth0接口
# ip route add default via 192.168.0.254 dev eth0 # 设置默认网关为192.168.0.254
# ip route del 192.168.4.0/24 # 删除192.168.4.0网段的网关
# ip route del default # 删除默认路由
|
按照方法,输入了 ip addr ,发现网卡eno16777736并没有IP地址。既然没有ip地址,那直接去/etc/sysconfig/network-scripts目录中看一下的网卡ip信息的配置文件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
[
root
@
localhost
~
]
# cd /etc/sysconfig/network-scripts
[
root
@
localhost
network
-
scripts
]
# ll
total
196
-
rw
-
r
--
r
--
.
1
root
root
288
Aug
18
22
:
36
ifcfg
-
eno16777736
-
rw
-
r
--
r
--
.
1
root
root
254
Sep
16
2015
ifcfg
-
lo
lrwxrwxrwx
.
1
root
root
24
Aug
18
22
:
48
ifdown
->
.
.
/
.
.
/
.
.
/
usr
/
sbin
/
ifdown
-
rwxr
-
xr
-
x
.
1
root
root
627
Sep
16
2015
ifdown
-
bnep
-
rwxr
-
xr
-
x
.
1
root
root
5817
Sep
16
2015
ifdown
-
eth
-
rwxr
-
xr
-
x
.
1
root
root
781
Sep
16
2015
ifdown
-
ippp
-
rwxr
-
xr
-
x
.
1
root
root
4201
Sep
16
2015
ifdown
-
ipv6
lrwxrwxrwx
.
1
root
root
11
Aug
18
22
:
48
ifdown
-
isdn
->
ifdown
-
ippp
-
rwxr
-
xr
-
x
.
1
root
root
1642
Sep
16
2015
ifdown
-
post
-
rwxr
-
xr
-
x
.
1
root
root
1068
Sep
16
2015
ifdown
-
ppp
-
rwxr
-
xr
-
x
.
1
root
root
837
Sep
16
2015
ifdown
-
routes
-
rwxr
-
xr
-
x
.
1
root
root
1444
Sep
16
2015
ifdown
-
sit
-
rwxr
-
xr
-
x
.
1
root
root
1462
Sep
16
2015
ifdown
-
tunnel
lrwxrwxrwx
.
1
root
root
22
Aug
18
22
:
48
ifup
->
.
.
/
.
.
/
.
.
/
usr
/
sbin
/
ifup
-
rwxr
-
xr
-
x
.
1
root
root
12631
Sep
16
2015
ifup
-
aliases
-
rwxr
-
xr
-
x
.
1
root
root
859
Sep
16
2015
ifup
-
bnep
-
rwxr
-
xr
-
x
.
1
root
root
11721
Sep
16
2015
ifup
-
eth
-
rwxr
-
xr
-
x
.
1
root
root
12039
Sep
16
2015
ifup
-
ippp
-
rwxr
-
xr
-
x
.
1
root
root
10430
Sep
16
2015
ifup
-
ipv6
lrwxrwxrwx
.
1
root
root
9
Aug
18
22
:
48
ifup
-
isdn
->
ifup
-
ippp
-
rwxr
-
xr
-
x
.
1
root
root
642
Sep
16
2015
ifup
-
plip
-
rwxr
-
xr
-
x
.
1
root
root
1043
Sep
16
2015
ifup
-
plusb
-
rwxr
-
xr
-
x
.
1
root
root
2609
Sep
16
2015
ifup
-
post
-
rwxr
-
xr
-
x
.
1
root
root
4154
Sep
16
2015
ifup
-
ppp
-
rwxr
-
xr
-
x
.
1
root
root
1925
Sep
16
2015
ifup
-
routes
-
rwxr
-
xr
-
x
.
1
root
root
3263
Sep
16
2015
ifup
-
sit
-
rwxr
-
xr
-
x
.
1
root
root
2682
Sep
16
2015
ifup
-
tunnel
-
rwxr
-
xr
-
x
.
1
root
root
1740
Sep
16
2015
ifup
-
wireless
-
rwxr
-
xr
-
x
.
1
root
root
4623
Sep
16
2015
init
.
ipv6
-
global
-
rw
-
r
--
r
--
.
1
root
root
15376
Aug
3
00
:
15
network
-
functions
-
rw
-
r
--
r
--
.
1
root
root
26134
Sep
16
2015
network
-
functions
-
ipv6
|
可以看到network-scripts目录下面的ifcfg-eth0变成了ifcfg-eno16777736。使用cat命令查看下ifcfg-eno16777736的内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[
root
@
localhost
network
-
scripts
]
# cat ifcfg-eno16777736
TYPE
=
Ethernet
BOOTPROTO
=
dhcp
DEFROUTE
=
yes
PEERDNS
=
yes
PEERROUTES
=
yes
IPV4_FAILURE_FATAL
=
no
IPV6INIT
=
yes
IPV6_AUTOCONF
=
yes
IPV6_DEFROUTE
=
yes
IPV6_PEERDNS
=
yes
IPV6_PEERROUTES
=
yes
IPV6_FAILURE_FATAL
=
no
NAME
=
eno16777736
UUID
=
ba6856dc
-
abf2
-
45e4
-
91d6
-
581eddab8d61
DEVICE
=
eno16777736
ONBOOT
=
no
|
从上面的配置中有看到虽然BOOTPROTO=dhcp,但是ONBOOT=no,这里用vi将ONBOOT=no改成ONBOOT=yes,然后重新系统或者重启网络即可:
1
|
systemctl
restart
network
.
service
|
原文地址:https://www.biaodianfu.com/centos-7-network-problem.html
更多推荐
所有评论(0)