ubuntu22.04 虚拟机 双网卡配置 桥接
1.添加一个新网卡

网卡类型选择桥接
 

 windows端win+R ipconfig
 
2.修改虚拟机网络配置
输入命令
ip a
 

 记录这里的ip地址
修改/etc/netplan/00-installer-config.yaml
sudo vim /etc/netplan/00-installer-config.yaml
 
修改为以下模样
network:
  ethernets:
    ens33:
      addresses: []
      dhcp4: true
    ens38:
      addresses: [你的ip地址/24(这个也是自己的)]
      dhcp4: false
      gateway4: 你的默认网关
      nameservers:
         addresses: [同上]
  version: 2
 
然后运行命令
sudo netplan apply
 
我的报了一个错误
 如下
fabric@fabric:/etc/netplan$ sudo netplan apply
** (generate:15158): WARNING **: 20:49:17.450: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.
** (process:15156): WARNING **: 20:49:17.568: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.
 
解决方法:
 修改/etc/netplan/00-installer-config.yaml
network:
   version: 2
   renderer: NetworkManager
   ethernets:
     ens34:
       dhcp4: no
       dhcp6: no
       addresses: [你的ip/24]
       routes:
         - to: default
           via: 172.16.13.1(默认网关)
       nameservers:
         addresses: [8.8.8.8,114.114.114.114]
                
本文来自博客园,作者:correct,转载请注明原文链接:https://www.cnblogs.com/correct/p/16548384.html

                
            
        
浙公网安备 33010602011771号