VyOS のインストール&初期セットアップ
VyOS を vSphere6 ESXi 上の仮想マシンにインストールした際のメモです。
仮想マシンの作成¶
VyOS は Debian ベースなので、仮想マシンのテンプレートは Debian を選択しました。事前にインターフェイスを(vSphere の最大である)10 個まで増やしておくと後々便利ですが、udev での認識順序と ESXi での認識順序が一致しないので要注意です。また、検証用途であれば予め serial port を追加しておくと便利です。
インストール¶
.iso イメージから起動すると以下のプロンプトになります。初期ログイン情報はユーザ名とパスワードが共に「vyos」です。
Welcome to VyOS - vyos ttyS0
vyos login: vyos
Password:
Linux vyos 3.13.11-1-amd64-vyos #1 SMP Fri Feb 27 21:07:15 UTC 2015 x86_64
Welcome to VyOS.
This system is open-source software. The exact distribution terms for
each module comprising the full system are described in the individual
files in /usr/share/doc/*/copyright.
vyos@vyos:~$
VyOS をローカルにインストールには install image を実行します。幾つか質問されますが、基本的にはデフォルト値で良いはずです。以下はインストール例です。
vyos@vyos:~$ install image
Welcome to the VyOS install program. This script
will walk you through the process of installing the
VyOS image to a local hard drive.
Would you like to continue? (Yes/No) [Yes]: yes
Probing drives: OK
Looking for pre-existing RAID groups...none found.
The VyOS image will require a minimum 1000MB root.
Would you like me to try to partition a drive automatically
or would you rather partition it manually with parted? If
you have already setup your partitions, you may skip this step
Partition (Auto/Parted/Skip) [Auto]:
I found the following drives on your system:
sda 8589MB
Install the image on? [sda]:
This will destroy all data on /dev/sda.
Continue? (Yes/No) [No]: yes
How big of a root partition should I create? (1000MB - 8589MB) [8589]MB:
Creating filesystem on /dev/sda1: OK
Done!
Mounting /dev/sda1...
What would you like to name this image? [1.1.5]:
OK. This image will be named: 1.1.5
Copying squashfs image...
Copying kernel and initrd images...
Done!
I found the following configuration files:
/config/config.boot
/opt/vyatta/etc/config.boot.default
Which one should I copy to sda? [/config/config.boot]:
Copying /config/config.boot to sda.
Enter password for administrator account
Enter password for user 'vyos':
Retype password for user 'vyos':
I need to install the GRUB boot loader.
I found the following drives on your system:
sda 8589MB
Which drive should GRUB modify the boot partition on? [sda]:
Setting up grub: OK
Done!
vyos@vyos:~$
インストールが完了したらメディアをアンマウントする為に一度、シャットダウンします。
シャットダウンが完了したら仮想マシンの設定から .iso イメージをアンマウントした後、仮想マシンを電源オンし直します。
ホスト名の設定¶
以下でホスト名を変更可能です。但し、ログイン中ユーザのログインプロンプトにホスト名を反映させる為には環境変数を再読み込みさせる必要がある為、ログアウト&ログインし直す必要があります。
インターフェイスの設定¶
WAN インターフェイス(PPPoE)の設定¶
PPPoE 接続時の設定例は以下の通りです。
set interfaces ethernet eth0 description '[DESCRIPTION]'
set interfaces ethernet eth0 pppoe 0 default-route auto
set interfaces ethernet eth0 pppoe 0 mtu 1414
set interfaces ethernet eth0 pppoe 0 name-server auto
set interfaces ethernet eth0 pppoe 0 password [PASSWORD]
set interfaces ethernet eth0 pppoe 0 user-id [USER-ID]
LAN インターフェイス(静的アドレス)の設定¶
set interfaces ethernet [INTERFACE] description '[DESCRIPTION]'
set interfaces ethernet [INTERFACE] address [ADDRESS/MASK]
ルーティングの設定¶
静的ルーティングの設定¶
サービスの設定¶
SSH サーバの設定¶
可能であれば SSH のポートもデフォルトの 22 から変更しておくべきです。
RSA 方式による公開鍵認証の設定は以下の通りです。
set system login user USERNAME authentication public-keys KEY key [BASE64]
set system login user USERNAME authentication public-keys KEY type ssh-rsa
デフォルトではパスワード認証が有効化されています。無効化するには以下を実行します。公開鍵認証方式を有効化し、問題無くログイン出来ることが確認出来ていればパスワード認証方式は無効化しておいた方がベターです。
NTP サーバの設定¶
デフォルトで ntp.org の NTP サーバが設定されています。これらを削除するには以下を実行します。
delete system ntp server 0.pool.ntp.org
delete system ntp server 1.pool.ntp.org
delete system ntp server 2.pool.ntp.org
NICT の NTP を参照するには、以下を設定します。
インターネットマルチフィードの NTP サーバを参照するには、以下を設定します。
set system ntp server ntp1.jst.mfeed.ad.jp
set system ntp server ntp2.jst.mfeed.ad.jp
set system ntp server ntp3.jst.mfeed.ad.jp
タイムゾーンの設定¶
ユーザの設定¶
新規ユーザの作成¶
デフォルトでは「vyos」という管理ユーザが必ず存在しますが、ユーザ名を推測されてしまう為、別に管理ユーザを作成した方が無難です。
set system login user [USERNAME]
set system login user [USERNAME] authentication plaintext-password '[PASSWORD]'
set system login user [USERNAME] level admin
ユーザの削除¶
デフォルトでは必ず「vyos」という名前のユーザが存在します。新規に管理ユーザを作成した場合は vyos ユーザを削除しておく方がベターです。
vyos ユーザを削除する場合は以下の通りです。
但し、この方法でユーザを削除してもコンフィグ上ではユーザの定義が残っているように見えます(ログインは出来ません)。どうしてもこれが許容出来ない場合は直接、/config/config.boot を編集してユーザの定義部分から不必要な部分を削除します。
NAT 設定¶
LAN から pppoe インターフェイスへの通信を pppoe0 のアドレスでマスカレードするには以下のように設定します。