Ubuntu21.04にKVM ( Kernel-based Virtual Machine )をインストール

1.依存パッケージをインストール
root@ubuntu:~# apt -y install qemu-kvm libvirt-daemon-system libvirt-daemon virtinst bridge-utils libosinfo-bin

略
hicolor-icon-theme (0.17-2) のトリガを処理しています ...
gnome-menus (3.36.0-1ubuntu1) のトリガを処理しています ...

2.ブリッジネットワークを構成
root@ubuntu:~# vi /etc/netplan/01-netcfg.yaml

network:
  ethernets:
    enp1s0:
      dhcp4: no
      dhcp6: no
  # ブリッジインターフェースを追記
  bridges:
    br0:
      interfaces: [enp1s0]
      dhcp4: no
      addresses: [192.168.0.30/24]
      gateway4: 192.168.0.1
      nameservers:
        addresses: [192.168.0.10]
      parameters:
        stp: false
      dhcp6: no 
  version: 2

root@ubuntu:~# netplan apply
IPアドレスの確認
root@ubuntu:~# ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:5f:a3:c6 brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.71.135/24 brd 192.168.71.255 scope global dynamic noprefixroute ens33
       valid_lft 1798sec preferred_lft 1798sec
    inet6 fe80::14e7:f18d:4b24:1019/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:13:19:34:66 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:04:49:9d brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
5: br0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 36:e8:a3:50:38:c5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.30/24 brd 192.168.0.255 scope global noprefixroute br0
       valid_lft forever preferred_lft forever

 

Ubuntu 21.04

Posted by arkgame