11

VirtualBox中Ubuntu20.04设置桥接网络.md

 3 years ago
source link: https://coolcao.com/2020/09/03/VirtualBox%E4%B8%ADUbuntu20.04%E8%AE%BE%E7%BD%AE%E6%A1%A5%E6%8E%A5%E7%BD%91%E7%BB%9C/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

VirtualBox中Ubuntu20.04设置桥接网络.md

2020-09-03

  |   技术博客

原创

  |   80

在虚拟机VirtualBox中安装UbuntuServer进行实验,默认使用NAT网络模式,但是宿主机无法联通虚拟机,因此将NAT模式改为桥接模式。

修改VirtualBox网络模式

1599100871_20200903103101181_2001375990.png

改完重启后,如果遇到ubuntu无法联网操作,那么需要手动设置网络。

查看宿主机网络

首先我们查看一下宿主机的网络,这里我使用的是Mac,如果你用的其他系统,可能操作和界面不大一样,但我们需要找到如下的信息:

1599100871_20200903103349509_1089900969.png
  1. 宿主机的ip地址,即上面的IPv4地址。
  2. 网关地址。即上面的路由器地址

设置Ubuntu网络

最新版的ubuntu已不在/etc/network/interfaces设置网络,取而代之的是在/etc/netplan/**.yaml中设置。

先切换到 /etc/netplan 目录下,查看这个目录下的文件:

1599100872_20200903103557158_2077560720.png
我的这台虚拟机上有个00-installer-config.yaml文件,你的可能名字不一致,但应该也是yaml文件。

编辑其中的内容:

1599100872_20200903103836882_1626404467.png

将dhcp4设置为false,因为我们要指定静态地址。
addresses为要设置的ip地址,这里要设置成和上面宿主机一样的网段的地址。
gateway4为要设置的网关地址,和宿主机网关地址一样。
nameservers为dns地址。

编辑完后保存,然后执行 sudo netplan apply 应用设置即可。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK