kvm配置虚拟机一般有几种模式,一般使用桥接和NAT两种模式
NAT模式:NAT模式会创建一个网关接口,然后虚拟机配置和这个网口同样地址的IP即可通过宿主机上网,但是外部无法访问虚拟机
桥接模式:可以KVM看作为物理网络上的一台独立的机器,需要占用单独的IP资源
我们来看看ubuntu20.04网络配置
cat /etc/netplan/01-network-manager-all.yaml # Let NetworkManager manage all devices on this system network: version: 2 renderer: NetworkManager
默认只有以上这些,我们可以添加网桥并设置静态IP
network: version: 2 renderer: NetworkManager ethernets: enp7s0: dhcp4: no dhcp6: no bridges: bridge0: interfaces: [enp7s0] dhcp4: no addresses: [192.168.1.71/24] gateway4: 192.168.1.1 nameservers: addresses: [114.114.114.114,8.8.8.8]
配置好了,我们使用
sudo netplan apply
让配置生效,或者也可以重启下虚拟机
接着可以使用命令查看网桥情况
brctl show bridge name bridge id STP enabled interfaces bridge0 8000.00e04c680b76 no enp7s0 vnet0 vnet1 vnet2 vnet3
创建以后还需要将虚拟机的网口都添加到这个网桥上
brctl addif bridge0 <vnet0...>
这样添加好了以后所有的虚拟机都可以设置独立IP进行上网了,配置IP地址通宿主机,网桥内的配置配置到上面enp7s0网卡下面即可,enp7s0是宿主机的网卡名,注意虚拟机可能网卡名字不是这个
内容版权声明:除非注明,否则皆为本站原创文章。
相关推荐
- ubuntu22.04编译安装postgresql17.5
- ubuntu使用deb包安装指定版本内核
- ubuntu修改grub引导切换到指定内核的方法
- ubuntu使用nvbandwidth测试单节点gpu带宽性能
- ubuntu24.04LTS添加apt源
- ubuntu下使用qperf工具测试RDMA网络带宽和延迟
- ubuntu22.04关闭自动更新和禁止unattended-upgrades服务开机启动
- ubuntu22.04使用nccl-tests进行单机多卡通信测试
- ubuntu22.04编译安装hwloc/libevent/ucx/openpmix/openmpi
- ubuntu安装openvpn并配置连接
评论列表