当前位置:网站首页>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
本文内容到此结束了,
如有收获欢迎点赞收藏关注️,您的鼓励是我最大的动力。
如有错误疑问欢迎各位大佬指出。
主页: 共饮一杯无的博客汇总保持热爱,奔赴下一场山海。

边栏推荐
- 类的初始化与实例化
- (mixed version 1) multiple TXT text to one table
- BIM and safety in road maintenance-buildSmart Spain
- Sleep quality today 79 points
- Ansible的playbook
- Fatal error: execution: there is no such file or directory
- 【MAUI】为 Label、Image 等控件添加点击事件
- Chapter 14 signals (IV) - examples of multi process tasks
- codeforces -- 4B. Before an Exam
- Double linked list related operations
猜你喜欢

"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

VS Code 设置单击打开新文件窗口,不覆盖前一个窗口
![leetcode:226. Flip binary tree [DFS flip]](/img/b8/6c5596ac30de59f0f347bb0bddf574.png)
leetcode:226. Flip binary tree [DFS flip]

基因检测,如何帮助患者对抗疾病?

Switch basic experiment

IOS interview

Common chart usage of Bi tools

leetcode:241. 为运算表达式设计优先级【dfs + eval】
![[JS] interview questions](/img/f3/8cf430b999980190a250f89537715e.jpg)
[JS] interview questions
![leetcode:241. Design priority for operation expression [DFS + Eval]](/img/d0/8dedeba7ecedccd25e0e3e96ff3362.png)
leetcode:241. Design priority for operation expression [DFS + Eval]
随机推荐
手机便签应用
Zero copy technology of MySQL
leetcode:226. 翻转二叉树【dfs翻转】
IOS interview
Compile and debug net6 source code
强大、好用、适合程序员/软件开发者的专业编辑器/笔记软件综合评测和全面推荐
Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing
R语言使用yardstick包的conf_mat函数计算多分类(Multiclass)模型在每个交叉验证(或者重采样)的每一折fold上的混淆矩阵、并使用summary输出每个fold的其它详细指标
A hole in solder paste
[JS advanced] promise explanation
项目部署,一点也不难!
VS Code 设置单击打开新文件窗口,不覆盖前一个窗口
Huawei interview question: Recruitment
【邂逅Django】——(二)数据库配置
JS related interview questions and answers (1)
Manage nodejs with NVM (downgrade the high version to the low version)
Fatal error: execution: there is no such file or directory
MySQL的零拷贝技术
leetcode:329. 矩阵中的最长递增路径【dfs + cache + 无需回溯 + 优雅】
网络socket的状态要怎么统计?