Linux虚拟机网络配置

Linux固定IP
跳转到 cd /etc/sysconfig/network-scripts/
打开文件并编辑 vim ifcfg-ens33 增加或修改选中内容
在这里插入图片描述
重启网卡 systemctl restart network
ifconfig -a 查看ip已固定
在这里插入图片描述

虚拟机网络编辑器调整
在这里插入图片描述

子网IP进行修改,例如本机IP修改为10.212.197.34 此处就修改为 10.212.197.0
在这里插入图片描述

修改完后在本机ping 下ip,数据通畅。

使用MobaXterm连接虚拟机特别慢。
打开 vim /etc/ssh/sshd_config 文件。

:/UseDNS搜索关键字
将UseDNS的注释去掉,并修改为no
在这里插入图片描述
重启ssh服务 systemctl restart sshd
重新使用MobaXterm连接虚拟机,速度正常,修改完成


2024.12.26
使用yum install -y 命令下载不了,重配yum源也不行,ping www.baidu.com 不通。
同时发现本机IP变成了10.212.197.137,而非ifcfg-ens33文件的10.212.197.34。
排查虚拟机网络配置。
1.虚拟机修改配置,IPv4 Method修改为手动。此处修改后,ifconfig -a 命令显示为ifcfg-ens33配置文件里的ip10.212.197.34,但是ping百度仍旧不通。
在这里插入图片描述

在这里插入图片描述
2.修改ifcfg-ens33配置文件内容

TYPE=Ethernet
BOOTPROTO=static
NAME=ens33
UUID=e1487cd2-12d3-48da-bbc2-32340fd893bb
DEVICE=ens33
ONBOOT=yes
IPADDR=10.212.197.34
NETMASK=255.255.255.0
GATEWAY=10.212.197.1
#DNS1=114.114.114.114
DNS1=8.8.8.8
PROXY_METHOD=none
BROWSER_ONLY=no
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no

3.查看本机网卡配置,ip地址需与ifcfg-ens33内的不一致(一样后MobaXterm连接不上),网关和子网掩码要一致。
在这里插入图片描述
4.修改VMware配置,网关要一致。此处修改一致后,ping www.baidu.com 正常。
在这里插入图片描述

5.重新配置yum源

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

后续执行yum install -y 命令正常。

新加一个,vmware启动蓝屏,豆包半天没找对答案,百度搜到的。
控制面板-程序-启用和关闭windows功能
勾选“虚拟机平台”(英文的话是 Virtual Machine Platform)和“Windows 虚拟机监控程序平台,之后重启。
https://zhuanlan.zhihu.com/p/4385503608

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值