当前位置:网站首页>VM虚拟机配置动态ip和静态ip访问
VM虚拟机配置动态ip和静态ip访问
2022-07-01 12:39:00 【51CTO】
VM虚拟机配置动态ip和静态ip访问
动态ip静态ip配置网络适配器都设置成NAT模式
动态ip配置
这个比较简单。
设置/etc/sysconfig/network-scripts/目录下的文件 ifcfg-ens33
配置文件如下即可
然后虚拟网络编辑器下设置NAT网络勾选这项就可以使用动态IP了
设置动态ip范围:
🥭静态ip配置
查看我们的PC无线网的默认网关(查看方式:设置-》查看网络属性)是多少,虚拟机的IP以及网关设置必须与PC无线网网关在同一个网段内才能实现通信
实际使用中一般使用静态IP,如果采用DHCP来自动获取IP的话 只要一断网 WM就会重新获取当前IP的下一个IP,所以必须改成静态的来防止这种尴尬的情况0.0
静态ip配置文件 ifcfg-ens33 如下
跟动态ip所不同的是设置了
BOOTPROTO=static为静态IP方式,
DNS1设置成 114.114.114.114 通用DNS
IPADDR 静态ip地址
NETMASK 子网掩码
GATEWAY 网关
注意ip要设置成与网关和子网同一段,同时子网掩码配置文件也要和配置保持一致。
网关如果设置成宿主机一样的还是ping不通外网和宿主机,就把网关最后一位设置成.2,如:192.168.2.2

然后虚拟网络编辑器下设置NAT网络切记不要勾选
配置完毕记得重启网卡配置systemctl restart network.service
设置域名解析
设置了静态ip,能访问外网,但是执行ping www.baidu.com不通,这时需要配置域名解析vi /etc/resolv.conf
本文内容到此结束了,
如有收获欢迎点赞收藏关注️,您的鼓励是我最大的动力。
如有错误疑问欢迎各位大佬指出。
主页: 共饮一杯无的博客汇总保持热爱,奔赴下一场山海。

边栏推荐
- Efforts at the turn of the decade
- Scene function of wooden frame
- [brain opening] west tide and going to the world series
- [JS advanced] promise explanation
- leetcode:241. 为运算表达式设计优先级【dfs + eval】
- 下半年还有很多事要做
- BIM and safety in road maintenance-buildSmart Spain
- [Maui] add click events for label, image and other controls
- Four years after graduation: work, resign, get married, buy a house
- There are still many things to be done in the second half of the year
猜你喜欢

VS Code 设置代码自动保存
![79. Word search [DFS + backtracking visit + traversal starting point]](/img/d6/a7693b2af435b7cf4562161ca4bd3f.png)
79. Word search [DFS + backtracking visit + traversal starting point]
![[JS] interview questions](/img/f3/8cf430b999980190a250f89537715e.jpg)
[JS] interview questions

be based on. NETCORE development blog project starblog - (13) add friendship link function

"Analysis of 43 cases of MATLAB neural network": Chapter 40 research on prediction of dynamic neural network time series -- implementation of NARX based on MATLAB

Ikvm of toolbox Net project new progress
![leetcode:241. Design priority for operation expression [DFS + Eval]](/img/d0/8dedeba7ecedccd25e0e3e96ff3362.png)
leetcode:241. Design priority for operation expression [DFS + Eval]

redis探索之缓存一致性

第十四章 信号(四)- 多进程任务示例

Four years after graduation: work, resign, get married, buy a house
随机推荐
ustime写出了bug
从数据库中更新一条数据,用cdc会同时获得op字段分别为d和c的两条数据吗?我记得之前是只有op为u
華為面試題: 招聘
[encounter Django] - (II) database configuration
ROS2 Foxy depthai_ros教程
Ikvm of toolbox Net project new progress
The difference between memcpy and strcpy
leetcode:329. The longest incremental path in the matrix [DFS + cache + no backtracking + elegance]
网络socket的状态要怎么统计?
be based on. NETCORE development blog project starblog - (13) add friendship link function
[Suanli network] technological innovation of Suanli Network -- key technology of operation service
Quickly understand what the compressed list in redis is
Chain storage of binary tree
Sleep quality today 79 points
Switch basic experiment
VS Code 设置代码自动保存
VS Code 设置单击打开新文件窗口,不覆盖前一个窗口
手机便签应用
Accept different views with an open mind
IOS interview