Skip to content

Ubuntu 24.04LTS 上で CML 用の VyOS 1.5 系イメージを作成する

以前に以下のメモを書きました。

VyOS は Get VyOS から VyOS nightly builds 版をダウンロード出来、現時点ではバージョン 1.5 系 (circinus) が公開されています。 ですが、公開されているのは .iso ファイルだけであり .qcow2 ファイルはリリースされていません。 そこで今回は CML 上で利用出来る VyOS の .qcow2 イメージを作成します。 尚、後述する理由から「cloud-init は無効」のイメージを作成します。

検証環境

対象 バージョン
Ubuntu 24.04LTS
CML 2.7.1
VyOS 1.5-rolling-202408110024

VyOS の必要スペックは Hardware requirements で以下のように記載されています。

The minimum system requirements are 1024 MiB RAM and 2 GiB storage. Depending on your use, you might need additional RAM and CPU resources e.g. when having multiple BGP full tables in your system.

VyOS のコードネーム

VyOS の OS バージョン毎のコードネームは以下だそうです。 current と記載されている場合、現時点では circinus のことを指しているようです。

バージョン コードネーム
1.2 crux
1.3 equuleus
1.4 sagitta
1.5 circinus

注意点

Ansible は 1.5 系に非対応?

VyOS は Ansible を使って各種の仮想化イメージ形式を作成出来る vyos-vm-images が公開されています。 ですが、1.2 系や 1.3 系は対応しているように見えるのですが、1.5 系のイメージを作成してみるとエラーにはならないものの、オプションの指定が悪かったのか「CML にインポートしてもプロンプトが表示されない」というイメージが出来上がってしまいました… (=ネットワークアクセスにも応答せず、利用出来ない)。

1.5 系には cloud-init を追加出来ない?

Nightly builds 版には cloud-init がインストールされておらず、cloud-init を利用したい場合は追加インストールする必要があります。 古い VyOS 1.2 系 (crux) であれば Create a vyos image with cloud-init to pull initial configuration from ISO の手順に従って cloud-init を追加出来たようです。

しかし VyOS Networks BlogCommunity, Contributors, User Base and LTS builds に背景事情が記載されているのですが、VyOS 専用の apt リポジトリは現在、原則非公開になっているようです。 VyOS 1.4 系専用のリポジトリ からディレクトリ / ファイル構造は見れるのですが、実際のファイルにアクセスしようとすると 403 Forbidden Error になってしまいます。 VyOS 1.5 系のリポジトリ はリダイレクトされるものの、各種ファイルへアクセスは出来るようです。 ですが apt の参照リポジトリへ追加しても公開されている GPG 鍵が古い為、今のところアクセスする方法が分かりません…

作業の流れ

作業の流れは大凡、以下の通りです。 qemu-guest-agent は予めインストールされていた為、追加インストールは不要でした。 また、残念ながら cloud-init を追加する手段が分からなかった為、cloud-init はインストール出来ませんでした…

  1. qemu のインストール
  2. VyOS の .iso ファイルダウンロード
  3. qemu イメージの作成
  4. CML へ qemu イメージのインポート

qemu のインストール

作業用の Ubuntu に Qemu をインストールします。

apt update && apt -y install qemu-system-x86

VyOS の qcow2 イメージ作成

Nightly builds 版の .iso ファイルをダウンロードします。

curl -LO https://github.com/vyos/vyos-rolling-nightly-builds/releases/download/1.5-rolling-202408120022/vyos-1.5-rolling-202408120022-amd64.iso

空のディスクイメージを作成します。 ディスクサイズは 8G にしました。

qemu-img create -f qcow2 vyos-1.5-rolling-202408120022-amd64.qcow2 8G

ダウンロードした .iso ファイルを CD-ROM としてマウントした状態で qemu で仮想マシンを起動します。 コンソール画面は 2001/TCP で待ち受けるようにオプション指定しています。 下記のコマンドを実行するとフォアグラウンドで qemu が実行される為、以降の作業は別ターミナル上で行います。

qemu-system-amd64 \
  -boot d \
  -cdrom vyos-1.5-rolling-202408120022-amd64.iso \
  -enable-kvm \
  -m 1024 \
  -serial telnet::2001,server,nowait,nodelay \
  -vnc :1 \
  vyos-1.5-rolling-202408120022-amd64.qcow2

(別ターミナル上で) 2001/TCP へ接続します。 下記では自分自身 (127.0.0.1 = localhost) の 2001/TCP へ接続していますが、別コンピュータから TELNET クライアントで 2001/TCP へ接続しても問題ありません。 しばらく待つと VyOS のログインプロンプトが表示されますので、以下の情報でログインします。

ユーザ名 パスワード
vyos vyos
# telnet 127.0.0.1 2001
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.

(...snip...)

Welcome to VyOS - vyos ttyS0

vyos login: vyos
Password:
Welcome to VyOS!

   ┌── ┐
   . VyOS 1.5-rolling-202408120022
   └ ──┘  current

 * Support portal: https://support.vyos.io
 * Documentation:  https://docs.vyos.io/en/latest
 * Project news:   https://blog.vyos.io
 * Bug reports:    https://vyos.dev

You can change this banner using "set system login banner post-login" command.

VyOS is a free software distribution that includes multiple components,
you can check individual component licenses under /usr/share/doc/*/copyright
vyos@vyos:~$

この状態では VyOS はローカルにインストールされておらず、live CD として動作しています。 その為、install image を実行して VyOS イメージをローカルディスクへインストールします。 複数回、入力を要求されますが今回は以下のように入力しました。

  1. Would you like to continue? [y/N]y
  2. What would you like to name this image? (Default: 1.5-rolling-202408120022)Enter
  3. Please enter a password for the "vyos" user:vyos
  4. Please confirm password for the "vyos" user:vyos
  5. What console should be used by default? (K: KVM, S: Serial)? (Default: S)Enter
  6. Which one should be used for installation? (Default: /dev/sda)Enter
  7. Installation will delete all data on the drive. Continue? [y/N]y
  8. Would you like to use all the free space on the drive? [Y/n]Enter
  9. Which file would you like as boot config? (Default: 1)Enter

実行例は以下の通りです。 ハイライト部分はユーザ入力が必要な部分です。

vyos@vyos:~$ install image
Welcome to VyOS installation!
This command will install VyOS to your permanent storage.
Would you like to continue? [y/N] y
What would you like to name this image? (Default: 1.5-rolling-202408120022)
Please enter a password for the "vyos" user:
Please confirm password for the "vyos" user:
What console should be used by default? (K: KVM, S: Serial)? (Default: S)
Probing disks
1 disk(s) found
The following disks were found:
Drive: /dev/sda (4.0 GB)
Which one should be used for installation? (Default: /dev/sda)
Installation will delete all data on the drive. Continue? [y/N] y
Searching for data from previous installations
No previous installation found
Would you like to use all the free space on the drive? [Y/n]
Creating partition table...
The following config files are available for boot:
    1: /opt/vyatta/etc/config/config.boot
    2: /opt/vyatta/etc/config.boot.default
Which file would you like as boot config? (Default: 1)
Creating temporary directories
Mounting new partitions
Creating a configuration file
Copying system image files
Installing GRUB configuration files
Installing GRUB to the drive
Cleaning up
Unmounting target filesystems
Removing temporary files
The image installed successfully; please reboot now.

これでローカルディスクへの VyOS イメージインストールは完了です。 poweroff now を実行して電源をオフにします。

vyos@vyos:~$ poweroff now

Broadcast message from root@vyos on pts/0 (Mon 2024-08-12 04:57:04 UTC):

The system will power off now!


[  257.194798] (sd-umount)[2408]: Failed to unmount /usr/lib/live/mount/medium: Device or resource busy
[  257.200807] systemd-shutdown[1]: Could not detach loopback /dev/loop0: Device or resource busy
[  257.263339] systemd-shutdown[1]: Failed to finalize file systems, loop devices, ignoring.
[  257.341701] reboot: Power down
Connection closed by foreign host.

VyOS の基本的な初期設定

VyOS の初期設定例は以下の通りです。

DHCP 設定例

configure
delete service ntp server 'time1.vyos.net'
delete service ntp server 'time2.vyos.net'
delete service ntp server 'time3.vyos.net'

set interfaces ethernet eth1 address dhcp

set service ntp server '162.159.200.1'
set service ntp server '162.159.200.123' prefer
set service ssh
set system domain-name 'example.com'
set system host-name 'vyos1'
set system login user admin authentication plaintext-password admin
set system name-server '1.0.0.1'
set system name-server '1.1.1.1'
set system time-zone 'Asia/Tokyo'
commit
exit

固定アドレス設定例

configure
delete service ntp server 'time1.vyos.net'
delete service ntp server 'time2.vyos.net'
delete service ntp server 'time3.vyos.net'

set interfaces ethernet eth1 address '10.0.0.1/24'
set protocols static route '0.0.0.0/0' next-hop '10.0.0.254'

set service ntp server '162.159.200.1'
set service ntp server '162.159.200.123' prefer
set service ssh
set system domain-name 'example.com'
set system host-name 'vyos1'
set system login user admin authentication plaintext-password admin
set system name-server '1.0.0.1'
set system name-server '1.1.1.1'
set system time-zone 'Asia/Tokyo'
commit
exit

参考