虚拟机联网(适用于Centos7.3 Centos7.9 Centos8.0)

虚拟机联网:

物理机先联网

  1. 直接使用桥接的网络适配器   通过获取ip   可以直接联网

注意   如果是新的主机   就不需要下面两台命令  

这两台命令   只用于配置了ip    需要重新获取ip

[root@localhost ~]# nmcli connection delete ens33

成功删除连接 'ens33'(cef656fd-0651-4534-8522-575e1ae4b7a1)。

[root@localhost ~]# nmcli connection add type ethernet ifname ens33 con-name ens33

连接“ens33”(e2fed819-1796-41ca-853e-4ae5dd1c67fc) 已成功添加。

 [root@localhost ~]# dhclient -d

 

[root@localhost ~]# ping www.baidu.com

PING www.a.shifen.com (39.156.66.18) 56(84) bytes of data.

64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=1 ttl=53 time=145 ms

连接不同的网络    ip会变化

  1. NAT模式的联网

自己配置一个ip     ip不会变化

[root@localhost ~]# nmcli connection modify ens33 ipv4.addresses 192.168.2.70/24

[root@localhost ~]# nmcli connection modify ens33 ipv4.gateway 192.168.2.1

[root@localhost ~]# nmcli connection modify ens33 ipv4.method manual

[root@localhost ~]# systemctl restart network

 

 

 

 

 

 

点两次确定

更改物理机上的配置

右键  属性

 

 

 

[root@localhost ~]# vim /etc/resolv.conf

nameserver 114.114.114.114

[root@localhost ~]# ping www.baidu.com

PING www.wshifen.com (104.193.88.77) 56(84) bytes of data.

 64 bytes from 104.193.88.77 (104.193.88.77): icmp_seq=1 ttl=128 time=215 ms

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数据库从删库到跑路

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值