VirtualBox网络设置

问题描述

上一篇文章中已经介绍了ubuntu系统在虚拟机中的安装,安装过后发现主机可以ping通虚拟机,可是虚拟机ping不通主机。

 

环境查看

主机网络

虚拟服务器网络

装完系统之后通过 ifconfig 命令只看到这两个网卡信息。这里请忽略马赛克部分。

 

解决步骤

打开VirtualBox,选择虚拟机,右键点击设置。进入设置页面后,选择网卡2点勾选启用,并按照图示完成其他配置。

 

重新启动系统,进入系统后输入以下命令查看系统网卡: 

 ls /sys/class/net

发现多了一个enp0s8

接下来配置这个网卡ip,首先切入到root用户

sudo su root  

编辑 interfaces

sudo vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface(NAT)
auto enp0s3
iface enp0s3 inet dhcp

auto enp0s8
iface enp0s8 inet static
address 192.168.56.101
netmask 255.255.255.0

重启服务器

reboot

 再次查看服务器ip信息

ifconfig

 

至此服务器网络设置完成。

更多请参考下面这篇文章

https://blog.csdn.net/dream_an/article/details/68484911

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值