虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

在进行配置虚拟机(linux CentOS 7 64bit)时,调试网络是否通,使用ping命令不能正常执行,报错为"connect: Network is unreachable"。

而调用ifconfig -a命令后,发现并没有eth0网卡,只有一个ens33和一个lo。

输入命令:cd /etc/sysconfig/network-scripts/

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

可输入命令将其ifcfg-ens33进行复制并重新命名为ifcfg-eth0

命令为:

cp -i ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

查看文件:

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

使用vi进行ifcfg-eth0文件中进行编辑,修改NAME和DEVICE所对应的值修改为eth0,然后增加MM_CONTROLLED=yes 和 HWADDR=00:50:********** 将ONBOOT值设置为yes

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

HWADDR值可以在网络适配是的高级中获取MAC地址信息。

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

虚拟机网络连接配置上选择了桥接模式所以IP也是自动获取

输入cd /etc/default命令

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

然后输入vi grub 

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

在GRUB_CMD_LINE_LINUX项中,插入" net.ifnames=0 biosdevname=0"

输入命令grub2-mkconfig -o /boot/grub2/grub.cfg更新配置,然后直接重启

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

重启后,进行输入ping www.baidu.com:

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

网络正常。

在输入ifconfig是查看IP地址,出现错误。

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

进行直接yum安装

yum install net-tools

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

输入ifconfig

虚拟机 connect: Network is unreachable问题,以及linux ifconfig命令不能使用

 

相关文章:

  • 2022-12-23
  • 2022-01-07
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
猜你喜欢
  • 2021-07-06
  • 2021-05-25
  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案