VirtualBox practical network settings

Practical scene

  • The company LAN ip is limited, in order not to waste LAN ip, abandoned the easiest set of virtual machines directly connected LAN bridging mode, using the method of this paper VirtualBox virtual machine network configuration.

Hardware and software environment

  • Win10 host system (hereinafter referred to as the host)
    • VirtualBox
      • Ubuntu_Client a virtual machine
      • Ubuntu_Server a virtual machine

Anticipated target

  • Host physical network card company LAN Internet connection. (Ip router automatically get from the company 192.168.0. * Network segment).
  • Establish a host on the 192.168.6. * LAN network and hosts, virtual machines are added to the network (so as not to occupy the company LAN ip)
  • Virtual machine can access the Internet and LAN servers within the company
  • LAN server can not access the virtual machine

Detailed Procedure

  • VirtualBox Network Manager Settings

    • Open VirtualBox Manager - Management - Host Network Manager
    删除列表中所有虚拟网卡(方便后面设置, 如本机有其他虚拟机网络设置, 此步骤请跳过)
    点击"创建" 创建一个虚拟网卡, 假如名称为:"VirtualBox Host-Only Ethernet Adapter"
    • Select "VirtualBox Host-Only Ethernet Adapter" card, the "card" choose to manually configure the network interface card
    IPv4地址 填 192.168.6.85 (主机ip, 根据实际需要填写, 这里为例子, 后面具体ip及掩码均为例子)
    IPv4网络掩码 填 255.255.255.0
    IPv6一般自动设置了, 不用填写.
    • Tab to switch to the "DHCP Server"
    勾选"启用服务器"
    服务器地址: 192.168.6.100
    服务器掩码: 255.255.255.0
    最小地址: 192.168.6.101
    最大地址: 192.168.6.254
    • Click "Apply" to exit the dialog box.
  • Ubuntu virtual network adapter settings

    • Select the virtual machine you want to modify, here assumed to be Ubuntu64_Client, click the "Settings" - "Network"
    在"网卡1"选项卡, 勾选"启用网络连接"
    连接方式选"仅主机(Host-Only)网络"
    界面名称: 下拉选择前文添加的虚拟网卡"VirtualBox Host-Only Ethernet Adapter"
    控制芯片默认
    混杂模式根据需要选择(我这里选择了拒绝)
    勾选"接入网线"
    • Switch to the "NIC 2" tab
    勾选"启用网络连接"
    连接方式选"网络地址转换(NAT)"
    勾选"接入网线"
    • After application to exit the dialog box, start the virtual machine Ubuntu64_Client
  • Ubuntu NIC configuration parameters (e.g., virtual machines do not want fixed ip, this step can be ignored)

    • sudo vi / etc / network / interfaces (different systems may be different network configuration file), set the parameters as follows (192.168.6.88 is the ip I want to set for Ubuntu64_Client):
    # interfaces(5) file used by ifup(8) and ifdown(8)
    auto lo
    iface lo inet loopback
    
    auto enp0s3
    iface enp0s3 inet static
    address 192.168.6.88
    netmask 255.255.255.0
    
    dns-nameservers 8.8.8.8
    
    auto enp0s8
    iface enp0s8 inet dhcp
    • Restart the virtual machine over a network or application changes.
    sudo service network-manager restart
  • Verify that the virtual machine network is successfully set

    ping www.baidu.com # 互联网正常
    ping 192.168.6.85 # 虚拟机到主机正常
    ping 192.168.0.115 # 公司局域网服务器正常
  • Ubuntu_Server repeat "Ubuntu virtual network adapter settings", "Ubuntu NIC configuration parameters" setting, not repeat them.

Guess you like

Origin www.cnblogs.com/nonsupport/p/12163184.html