FAIRYFAR-INTERNAL
 
  FAIRYFAR-INTERNAL  |  SITEMAP  |  ABOUT-ME  |  HOME  
VirtualBox虚拟机网络配置

环境

宿主机为Windows,内网使用有线连接,IP为192.168.0.100;无线网卡连接公网。虚拟机为openEuler 23.03。

宿主机配置

VirtualBox中为虚拟机设置两块网卡:

一块使用宿主机的无线网卡,”连接方式“设为”桥接网卡“。

image

另一块使用宿主机的有线网卡,”连接方式“也设为”桥接网卡“。

image

虚拟机配置

然后启动虚拟机,执行ifconfig查看网卡信息:

snippet.bash
[root@bogon ~]# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
……
        ether 08:00:27:66:a6:b8  txqueuelen 1000  (Ethernet)
……
 
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
……
        ether 08:00:27:f2:e0:40  txqueuelen 1000  (Ethernet)
……

“ether”信息与虚拟网卡的MAC地址有对应关系。

配置每块网卡的network-script:

snippet.bash
[root@bogon ~]# vim /etc/sysconfig/network-scripts/ifcfg-enp0s3
BOOTPROTO=dhcp
DEFROUTE=yes
NAME=enp0s3
DEVICE=enp0s3
ONBOOT=yes
 
[root@bogon ~]# vim /etc/sysconfig/network-scripts/ifcfg-enp0s8
BOOTPROTO=static
NAME=enp0s8
DEVICE=enp0s8
ONBOOT=yes
IPADDR=192.168.0.100
NETMASK=255.255.255.0

重启网卡:

snippet.bash
[root@bogon ~]# ifdown enp0s3
[root@bogon ~]# ifup enp0s3
[root@bogon ~]# ifdown enp0s8
[root@bogon ~]# ifup enp0s8

或者,

snippet.bash
[root@bogon ~]# nmcli c reload

参考



打赏作者以资鼓励:
移动端扫码阅读: