VBox配置虚拟机固定IP可上网

2019-06-29 16:52:07

vbox全局设置:

虚拟机设置:

主机网卡文件配置:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
HWADDR=08:00:27:48:8B:72
TYPE=Ethernet
UUID=324061e8-25e0-4ca6-8747-a30ec1610d9f
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp

vi /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1
HWADDR=08:00:27:6F:55:A4
TYPE=Ethernet
UUID=3d97ced7-3e22-4f4a-90db-537bf01c99b2
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=172.32.115.60
NETMASK=255.255.255.0

  注意:此文件中配置的 IPADDR=172.32.115.60 与 截图2中Host-Only配置的 IPv4地址 中的IP不能重复!!!

  重启网卡:service network restart

 

 

新增:Ubuntu网络配置

sudo vim /etc/netplan/01-network-manager-all.yaml

# Let NetworkManager manage all devices on this system
network:
  ethernets:
    enp0s8:
      addresses: [137.32.117.30/24]
      dhcp4: no
      optional: true
      gateway4: 137.32.117.1
      nameservers:
        addresses: [137.32.117.1,114.114.114.114]
  version: 2
  renderer: NetworkManager

  执行 sudo netplan apply 使配置生效

  注意:Ubuntu自带的vi编辑版本方向键默认是ABCD,卸载重装即可解决

posted @ 2019-06-29 17:01  人间丶迷走  阅读(2666)  评论(0编辑  收藏  举报